Older versions of Python (2.3 - 3.10) used an algorithm called Timsort:

Timsort is a hybrid sorting algorithm, derived from merge sort and insertion sort, designed to perform well on many kinds of real-world data. It was invented by Tim Peters in 2002 for use in the Python programming language. The algorithm finds subsets of the data that are already ordered, and uses the subsets to sort the data more efficiently. This is done by merging an identified subset, called a run, with existing runs until certain criteria are fulfilled. Timsort was Python's standard sorting algorithm from version 2.3 to version 3.10. It is now also used to sort arrays in Java SE 7, and on the Android platform.

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.

Answer from bgporter on Stack Overflow
Discussions

what sorting algorithm does sort() function use ?
It's none of those. It's a hybrid algorithm called Timsort . More on reddit.com
๐ŸŒ r/Python
6
1
August 5, 2020
What sorting algorithm does python used for list.sort() ??
http://www.hatfulofhollow.com/posts/code/timsort/index.html http://bugs.python.org/file4451/timsort.txt More on reddit.com
๐ŸŒ r/Python
14
40
August 11, 2009
๐ŸŒ
Python documentation
docs.python.org โ€บ 3 โ€บ howto โ€บ sorting.html
Sorting Techniques โ€” Python 3.14.6 documentation
>>> def multisort(xs, specs): ... ... ('age', False))) [('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)] The Timsort algorithm used in Python does multiple sorts efficiently because it can take advantage of any ordering ...
๐ŸŒ
Wikipedia
en.wikipedia.org โ€บ wiki โ€บ Timsort
Timsort - Wikipedia
February 17, 2026 - Timsort was Python's standard sorting algorithm from version 2.3 until it was replaced in 3.11 by Powersort, a derived algorithm with a more robust merge policy. Timsort is also used to sort arrays of non-primitive type in Java SE 7, on the Android platform, in GNU Octave, on V8, and in Swift.
๐ŸŒ
Xccelerate
xccelerate.co โ€บ blog โ€บ 6-types-of-sorting-algorithms-to-use-in-python
6 Types Of Python Sorting Algorithms | Xccelerate
July 2, 2024 - For instance, if you have an integer array with random numbers (comparable values), here is how the algorithm would work: This built-in function for sorting in Python makes use of the Timsort algorithm, an advanced hybrid version of Insertion ...
๐ŸŒ
Educative
educative.io โ€บ answers โ€บ what-is-the-python-sorted-function
What is the Python sorted() function?
In the case of strings and characters, sorting is done based on their ASCII values. ... The Python sorted() uses the Timsort algorithm which is a hybrid sorting algorithm, derived from merge sort and insertion sort.
๐ŸŒ
Quora
quora.com โ€บ Which-sorting-algorithm-is-used-by-Python-in-the-sort-method
Which sorting algorithm is used by Python in the sort() method? - Quora
The algorithm that is used in python sort() function is TimSort which is based on Insertion and Merge sort .
Find elsewhere
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ sorting-algorithms-in-python
Sorting Algorithms in Python - GeeksforGeeks
April 9, 2025 - It was Created by Tim Peters in 2002, Tim Sort is the default sorting algorithm in Python and is renowned for its speed and efficiency in real-world data scenarios. ... Comb Sort is an improvement over Bubble Sort, and it aims to eliminate the ...
๐ŸŒ
Towards Data Science
towardsdatascience.com โ€บ home โ€บ latest โ€บ sorting algorithms โ€“ with python
Sorting Algorithms - With Python | Towards Data Science
March 5, 2025 - After trying all of these different algorithms, just for curiosity I submitted my solution with the default sort method. It was pretty fast with a runtime of 152 (ms). Pythonโ€™s default sort uses Tim Sort, which is a combination of both merge ...
๐ŸŒ
Medium
medium.com โ€บ ub-women-data-scholars โ€บ the-magic-behind-the-sort-algorithm-in-python-1cb9515294b5
The magic behind the sort algorithm in Python | by Angela Heumann | Women Data Greenhorns | Medium
August 8, 2018 - The Timsort algorithm used in Python takes advantage of both Insertion and Merge algorithms and therefore is a solid tool for most use cases in Data Science. Additionally, it does provide a wide range of sorting possibilities in the form of ...
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ python_data_structure โ€บ python_sorting_algorithms.htm
Python - Sorting Algorithms
Merge sort first divides the array into equal halves and then combines them in a sorted manner.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ fastest-way-to-sort-in-python
Fastest Way to Sort in Python - GeeksforGeeks
July 23, 2025 - sorted() function is a built-in Python function that returns a new list containing all elements from the original list in sorted order. It uses Timsort algorithm which has a time complexity of O(n log n) in the worst case.
๐ŸŒ
Analytics Vidhya
analyticsvidhya.com โ€บ home โ€บ complete guide on sorting techniques in python [2025 edition]
Complete Guide on Sorting Techniques in Python [2025 Edition] - Analytics Vidhya
November 28, 2024 - The `sort()` method is available for lists in Python. It sorts the list in-place, modifying the original list. The `sort()` method also uses the Timsort algorithm. ... The `numpy` library provides efficient sorting functions for arrays and matrices.
๐ŸŒ
Quora
quora.com โ€บ How-does-the-Python-sort-function-work-internally
How does the Python sort function work internally? - Quora
Answer (1 of 3): Python uses Timsort which is a sorting algorithm developed originally for Python by Tim Peters and subsequently adopted by several other languages. Timesort is a modified merge sort intended to work well with common cases where the data is already partly ordered while still bein...
๐ŸŒ
Stack Abuse
stackabuse.com โ€บ sorting-algorithms-in-python
Sorting Algorithms in Python
October 24, 2023 - As the input being recursed is half of what was given, like binary trees this makes the time it takes to process grow logarithmically to n. Therefore the overall time complexity of the Merge Sort algorithm is \(O(nlog(n))\). This divide and conquer algorithm is the most often used sorting algorithm ...
๐ŸŒ
Stanford CS
cs.stanford.edu โ€บ people โ€บ nick โ€บ py โ€บ python-sort.html
Python Sorting
(In CS106B you'll design and analyze your own sort algorithm.) Here we'll look at the sorted() function which works on any linear data structure. The sorted() function orders the elements into increasing order. The elements can be any type (str, int, float, ..) so long as that type supports < and ==. The simplest use of sorted is just ordering a linear series of strs or ints into increasing order.
๐ŸŒ
Software Testing Help
softwaretestinghelp.com โ€บ home โ€บ python โ€บ python sort: sorting methods and algorithms in python
Python Sort: Sorting Methods And Algorithms In Python
April 1, 2025 - All the sorting techniques are efficient and easy to understand. ... Answer: The sort() function takes the given array as an input from the user and sorts it in a specific order using the sorting algorithm.
๐ŸŒ
Python
docs.python.org โ€บ 3.10 โ€บ โ€บ howto โ€บ sorting.html
Sorting HOW TO โ€” Python 3.10.20 documentation
>>> def multisort(xs, specs): ... for key, reverse in reversed(specs): ... xs.sort(key=attrgetter(key), reverse=reverse) ... return xs >>> multisort(list(student_objects), (('grade', True), ('age', False))) [('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)] The Timsort algorithm used in ...
๐ŸŒ
101 Computing
101computing.net โ€บ home โ€บ python challenges โ€บ sorting algorithms using python
Sorting Algorithms using Python - 101 Computing
August 11, 2024 - We have implemented each these algorithms below, using Python to sort a set list of values. ... The insertion sort is an iterative algorithm (using nested loops). The Bubble sort is an iterative algorithm (using nested loops).