Jak sortować listę w kolejności malejącej w Pythonie
#1 Changes list
list.sort(reverse=True)
#2 Returns sorted list
sorted(list, reverse=True)
MitroGr
#1 Changes list
list.sort(reverse=True)
#2 Returns sorted list
sorted(list, reverse=True)
sorted(timestamps, reverse=True)
>>> sorted(student_tuples, key=itemgetter(2), reverse=True)
[('john', 'A', 15), ('jane', 'B', 12), ('dave', 'B', 10)]
>>> sorted(student_objects, key=attrgetter('age'), reverse=True)
[('john', 'A', 15), ('jane', 'B', 12), ('dave', 'B', 10)]