I have a nested list:
list = [[3,2,1],[8,7,9],[5,6,4]]
I want to sort each sublist in ascending order. My though was to loop through the list, but it only wants to sort the last sublist.
for i in list:
newList = sorted[i]
So for this example the for loop would loop through the whole list, but only sort the last sublist [5,6,4]. How do I make it sort all the sublists?
Python version: 2.7.10
OS: OS X El Capitan
i.sort(). That sorts the (sub)list in-place.