My data structure is a list of tuples in Python, and I’d like to be able to sort the list items by a value contained in their tuples. In PHP, I’d normally create my own sorting function with usort(). Is there an equivalent in Python I could use?
Share
Give the
sort()method akeyfunction:If you need to get a sorted list, instead of sorting in place, use the built_in
sorted()