VladimirMikulic's solution to "Sub-sorting lists in Python3"

Solution<\/h1>\n\n

list_a=[
\n ['Arch', '#1 ', 11, ' 3.36'],
\n ['PM', '#2 ', 10, ' 2.20'],
\n ['PM', '#3 ', 10, ' 2.80'],
\n ['PM', '#4 ', 10, ' 2.85'],
\n ['PM', '#5', 10, ' 3.00' ],
\n ['PM', '#6', 10, ' 3.10' ],
\n ['SD', '#7 ', 9, ' 2.67' ],
\n ['I&O', '#8 ', 9, ' 2.89']
\n]<\/p>\n\n

list_b = sorted(list_a, key=lambda x: x[3])<\/p>\n\n

print(list_b)<\/p>\n

# Solution list_a=[ ['Arch', '#1 ', 11, ' 3.36'], ['PM', '#2 ', 10, ' 2.20'], ['PM', '#3 ', 10, ' 2.80'], ['PM', '#4 ', 10, ' 2.85'], ['PM', '#5', 10, ' 3.00' ], ['PM', '#6', 10, ' 3.10' ], ['SD', '#7 ', 9, ' 2.67' ], ['I&O', '#8 ', 9, ' 2.89'] ] '] ] // Ascending list_b = sorted(list_a, key=lambda x: x[3]) ]) // Descending list_b = sorted(list_a, key=lambda x: x[3], reverse=True) print(list_b)

User: VladimirMikulic

Question: Sub-sorting lists in Python3

Back to question