Is there a more Pythonic, compact, intuitive way to sort letter-grades than this (without using a custom dict)?
grades = [\'B-\',\'C\',\'B\',\'C+\',\'A\',\'D+\',
No.
modmap = { '-': 0, '': 1, '+': 2 } print(sorted(grades, key=lambda x: (-ord(x[0]), modmap[x[1:]])))