Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

how to sort a list of lists in python

from operator import itemgetter
A = [[10, 8], [90, 2], [45, 6]]
print("Sorted List A based on index 0: % s" % (sorted(A, key=itemgetter(0))))
B = [[50, 'Yes'], [20, 'No'], [100, 'Maybe']]
print("Sorted List B based on index 1: % s" % (sorted(B, key=itemgetter(1))))
Source by www.delftstack.com #
 
PREVIOUS NEXT
Tagged: #sort #list #lists #python
ADD COMMENT
Topic
Name
8+5 =