What is the best way to sort list with custom sorting parameters in Python?
Question: I have a series of lists that looks like this:

    
    
    li1 = ['a.1', 'b.9', 'c.8', 'd.1', 'e.2']
    li2 = ['a.4', 'b.1', 'c.2', 'd.2', 'e.4']
    

How can I rearrange the items in each list so that the first item is
'b.something'? For the example above:

    
    
    li1 = ['b.9', 'a.1', 'c.8', 'd.1', 'e.2']
    li2 = ['b.1', 'a.4', 'c.2', 'd.2', 'e.4']
    

Maintaining the order after the first item isn't important. Thanks for the
help.


Answer: Python's sorting is stable, so you will maintain the order after the first
item regardless.

    
    
    li1.sort(key=lambda x: not x.startswith('b.'))
    

