In Python 2.7, how does Python’s built-in sorted function work – what algorithm does it use?
In Python 2.7, how does Python’s built-in sorted function work – what algorithm does
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Older versions of Python (2.3 – 3.10) used an algorithm called Timsort:
Since 3.11, Python uses Powersort, which was designed by Ian Munro and Sebastian Wild. It is an improved nearly-optimal mergesort that adapts to existing runs of sorted data.