What is the result of calling `sorted()` on a list of tuples like `[(2,’b’),(1,’a’),(2,’a’)]` by default?

Python Professional Hard

Python Professional — Hard

What is the result of calling `sorted()` on a list of tuples like `[(2,’b’),(1,’a’),(2,’a’)]` by default?

Key points

  • `sorted()` by default sorts tuples lexicographically
  • Lexicographical sorting means sorting by the first element first
  • If there are ties in the first element, it will then sort by the second element

Ready to go further?

Related questions