What would be an elegant way to represent an arbitrary total order between elements of a list in Python, e.g. the function torder in the following example (where C>B>A). Edit: I assume the list defines the order:
>>> s = ['A','B','C']
>>> torder('B')
['A']
>>> torder('C')
['A','B']
I could do that using if and elif if the list is short but was looking for something more pythonic.
1 Answer