I want to sort a list of strings in reverse order, e.g.:
my_list = [\'aaa\', \'bbb\', \'ccc\']
expected result:
[\'ccc\', \
You can do a negative ord
on the value and that would work for an ascii string:
>>> sorted(my_list2, key=lambda x: ([-ord(l) for l in x[0]], x[1]))
[('bbb', 'aaa'), ('bbb', 'ccc'), ('aaa', 'bbb'), ('aaa', 'ccc')]
For non-ascii though you'd have choices in how you'd want to sort though:
>>> sorted(my_list2, key=lambda x: ([-ord(l) for l in x[0]], x[1]))
[('ébb', 'écc'), ('bbb', 'aaa'), ('aaa', 'bbb'), ('aaa', 'ccc')]