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
🌐
Python documentation
docs.python.org › 3 › howto › sorting.html
Sorting Techniques — Python 3.14.6 documentation
Author, Andrew Dalke and Raymond Hettinger,. Python lists have a built-in list.sort() method that modifies the list in-place. There is also a sorted() built-in function that builds a new sorted lis...
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
Selection Sort algorithm
I am learning algorithmic design. As I am tackling Bubble Sort in another thread, I am venturing to explore a similar and related algorithm: Selection Sort. While bubble sort compares each element next to each other and swaps positions until the largest integer value is “bubbled up” or ... More on discuss.python.org
🌐 discuss.python.org
5
0
August 14, 2024
Is it always better to build your own sorting algorithms?
Usually you use the built in sorting algorithms. But they are good for teaching algorithm and runtime calculation. Same with trees and hash tables. More on reddit.com
🌐 r/compsci
90
168
April 25, 2021
A new sorting algorithm for 2025, faster than Powersort!
I'd love to see some repeatable unit and integration tests as well as some side-by-side comparisons, especially around speed. I'm super dubious of anything that claims to be so much faster than the standard implementation. More on reddit.com
🌐 r/Python
29
146
February 13, 2025
🌐
GeeksforGeeks
geeksforgeeks.org › python › sorting-algorithms-in-python
Sorting Algorithms in Python - GeeksforGeeks
December 12, 2025 - The different implementations of sorting techniques in Python are: ... Bubble Sort is the simplest sorting algorithm that works by repeatedly swapping the adjacent elements if they are in the wrong order.
🌐
Real Python
realpython.com › sorting-algorithms-python
Sorting Algorithms in Python – Real Python
November 27, 2023 - In this example, run_sorting_algorithm() receives the name of the algorithm and the input array that needs to be sorted. Here’s a line-by-line explanation of how it works: Line 8 imports the name of the algorithm using the magic of Python’s f-strings. This is so that timeit.repeat() knows where to call the algorithm from.
🌐
Mga
comp.mga.edu › learning › python › module › 20
20. Sorting Algorithms
Write a Python function that takes a list of numbers and an integer k as input and returns the top-k elements from the list, sorted in descending order. You can use sorting algorithms like quick select to efficiently find the top-k elements.
Find elsewhere
🌐
W3Schools
w3schools.com › python › python_dsa_bubblesort.asp
Bubble Sort with Python
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Practice Problems Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Training ... Bubble Sort is an algorithm that ...
🌐
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 - Python has an in-built sorting function that can be called using sorted(). For instance, if you have an integer array with random numbers (comparable values), here is how the algorithm would work:
🌐
Zax Rosenberg
zaxrosenberg.com › must-know-sorting-algorithms-in-python
Must-Know Sorting Algorithms in Python - Zax Rosenberg
January 3, 2018 - Heap sort is an improved version of selection sort, which takes advantage of a heap data structure (a special instance of a complete binary tree where the value of the parent node is greater than the values of its two children nodes) rather than a linear-time search to find the max value item. ... That’s a lot of code to write. Luckily for us, we can make use of python’s built-in heap data structure instead: ... Timsort. Timsort is the algorithm used by Python’s built-ins sort() and sorted() (since version 2.3), and used both merge sort and insertion sort.
🌐
Medium
medium.com › data-science › sorting-algorithms-with-python-4ec7081d78a1
Sorting Algorithms — With Python
January 22, 2023 - 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 ...
🌐
Stanford CS
cs.stanford.edu › people › nick › py › python-sort.html
Python Sorting
Stable - a common feature of good sort algorithm is that it only re-orders elements from the original if they are not ==. So if we had 2 copies of the ('stanford.edu', '/admit') tuple in that list, they would stay in the same order after sorting. The built in sorting algorithm is stable in this way. Say you have a list of strings, and you want to sort in a way other than alphabetic. Python has a very nice way to do this, the "key" function.
🌐
Python.org
discuss.python.org › python help
Selection Sort algorithm - Python Help - Discussions on Python.org
August 14, 2024 - I am learning algorithmic design. As I am tackling Bubble Sort in another thread, I am venturing to explore a similar and related algorithm: Selection Sort. While bubble sort compares each element next to each other and swaps positions until ...
🌐
Quora
quora.com › Which-sorting-algorithm-does-Python-Sorted-use
Which sorting algorithm does Python Sorted use? - Quora
Answer: It uses TimSort, a sort algorithm which was invented by Tim Peters, and is now used in other languages such as Java. TimSort is a complex algorithm which uses the best of many other algorithms, and has the advantage of being stable - in others words if two elements A & B are in the order...
🌐
Medium
medium.com › @sulthanm2d › sort-method-algorithm-in-python-359888ed8975
Sorting Algorithm in Python: Bubble Sort, Insertion Sort, and Merge Sort | by Sulthanm2d | Medium
December 14, 2023 - Insertion sort is like bubble sort, it is easy to understand. However, unlike bubble sort, it arranges the list gradually by checking each item against the rest and placing it in the right spot.
🌐
Codecademy
codecademy.com › learn › sorting-algorithms › modules › cs-bubble-sort › cheatsheet
Learn Sorting Algorithms with Python: Bubble Sort Cheatsheet | Codecademy
Bubble sort works by iterating through a list and checking whether the current element is larger or smaller than the next element. This algorithm consists of an outer iteration and an inner iteration. In the inner iteration, the first and second elements are first compared and swapped so that the second element has a higher value than the first.
🌐
GitHub
github.com › B3ns44d › Python_Sorting_Algorithms
GitHub - B3ns44d/Python_Sorting_Algorithms: Python - Sorting Algorithms · GitHub
It simple uses the 2 main steps of such an algorithm: (1) Continuously divide the unsorted list until you have N sublists, where each sublist has 1 element that is “unsorted” and N is the number of elements in the original array.
Starred by 25 users
Forked by 61 users
Languages   Python
🌐
TutorialsPoint
tutorialspoint.com › python_data_structure › python_sorting_algorithms.htm
Python - Sorting Algorithms
Below we see five such implementations of sorting in python. ... It is a comparison-based algorithm in which each pair of adjacent elements is compared and the elements are swapped if they are not in order.
🌐
iO Flood
ioflood.com › blog › python-sort-algorithms
Python Sort Algorithms: A Comprehensive Guide
February 6, 2024 - Quicksort is a divide-and-conquer algorithm. It works by selecting a ‘pivot’ element from the array and partitioning the other elements into two sub-arrays, according to whether they are less than or greater than the pivot.