Sort list of tuples by value Python
Question: I've got a list of tuples as the example:

    
    
    result = [(1, 6.06), (2, 6.23), (3, 7.03), (4, 6.88), (5, 6.43), (6, 6.57)]
    

How can I sort the list by value in descending order?


Answer: Probably something like:

    
    
    result.sort(key=lambda x:x[1],reverse=True)
    

Or some prefer

    
    
    from operator import itemgetter
    result.sort(key=itemgetter(1),reverse=True)
    

...

or perhaps just:

    
    
    result.sort(reverse=True)
    

depending on what you mean by `value`.

If you don't want to sort the list in place, you can always use `sorted` in
much the same way. Of course, the canonical guide to how to sort in python is
found at the following link: ["Sorting Mini-HOW
TO"](http://wiki.python.org/moin/HowTo/Sorting/)

