python - Method to sort a list of lists? -


i have list of lists (can't tuples since have generate dynamically) , structured list of lists of 1 int , 1 float so:

[[1,1.0345],[2,5.098],[3,4.89],[2,5.97]] 

i want sorted have managed built in sorting function sort first element of lists or not anything, need sort them second element of list , don't want implement own sorting function. example of want is:

[[1,1.0345],[3,4.89],[2,5.098],[2,5.97]] 

could tell me how 1 of built in sorting functions this?

pass key argument.

l.sort(key=operator.itemgetter(1)) 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -