+ 1
How to sort a list or set based on second item in python
a list might contain a list in itself so how to sort a list based on the second item in the inner list
4 Respostas
+ 2
[["A",10],["B",5]]
the text below should be the output...the sorting should happen based on second element
[["B",5],["A",10]]
+ 1
consider one list here,
l = [12,10,20,39,[1,6,11,19,22],23,5,6]
Can you please tell how it looks a like after sort?
inner list may have smaller/bigger value than outer list.
Could you please tell why do you need such a requirement?
+ 1
you can iterate over list and copy into dictionary and sort dictionary per value and again iterate over dictionary and restore the sorted things into list.
make sense?
+ 1
print(sorted([['A',10],['B',5]], key=lambda colonnes: colonnes[1]))