Python How to sort list in a list
<p>I'm trying to sort a list within a list. This is what I have. I would like to sort the inner namelist based on alphabetical order. Have tried using loops but to no avail. The smaller 'lists' inside happens to be strings so I can't sort() them as list. Error: 'str' object has no attribute 'sort'</p>

<pre><code>Names = [
    [['John'] ['Andrea', 'Regina', 'Candice'], ['Charlotte', 'Melanie'], 
    ['Claudia', 'Lace', 'Karen'] ['Ronald', 'Freddy'], 
    ['James', 'Luke', 'Ben', 'Nick']]
]
</code></pre>

<p>I would like it to be sorted into: </p>

<pre><code>[
    [['John'] ['Andrea', 'Candice', 'Regina'], ['Charlotte', 'Melanie'], 
    ['Claudia', 'Karen', 'Lace'] ['Freddy', 'Ronald'], 
    ['Ben', 'James', 'Luke', 'Nick']]
]
</code></pre>

<p>Thank you. 
Edit: Sorry i made a mistake in the previous codes. Ive since edited it.</p>

<p>The built - in list method: <code>sort()</code> works in-place on sub lists if you iterate over them:</p>

<pre><code>Names = [['John', 'Andrea', 'Regina', 'Candice', 'Charlotte', 'Melanie'], ['Claudia', 'Lace', 'Karen', 'Ronald', 'Freddy'], ['James', 'Luke', 'Ben', 'Nick']

for sublist in Names:
    sublist.sort()
</code></pre>

python string list sorting