Thursday, 12 September 2013

Sort a list of lists according to another list

Sort a list of lists according to another list

How would you sort lista according to order of items in sorter_list:
lista = [["John", "B3"],["Robert", "P3"], ["Thomas", "S2"]]
sorter_list = ["P3", "S2", "B3"]
and result will be:
sorted_lista = [ ["Robert", "P3"], ["Thomas", "S2"], ["John", "B3"]]
Regards

No comments:

Post a Comment