Provided itemgetter(0) is O(1) when used with data, the sort is O(n log n) both on average and in the worst case.

For more information on the sorting method used in Python, see Wikipedia.

Answer from NPE on Stack Overflow
Discussions

What time complexity should one assume when using built in sort functions?
aromatic ripe concerned mountainous racial gray chop coherent wild lavish This post was mass deleted and anonymized with Redact More on reddit.com
🌐 r/leetcode
11
15
April 15, 2024
Why is the time complexity of sorting an array of strings not a function of the length of each string?
Sorting an array is (for a good sorting algorithm) O(n log n) * O(time for one comparison). In many scenarios a comparison is either O(1) or negligible compared to n. Even when sorting strings, if we assume the strings have an arbitrary but finite length m, then the comparison time becomes negligible as n approaches infinity while m remains constant, so the runtime simplifies to O(n log n). For example, if you're sorting records by usernames, and usernames are a maximum of twenty characters, then comparing usernames is O(1) because you're comparing a maximum of twenty pairs of characters. But yes, if the length of the strings is a free variable then the overall runtime should be O(m n log n). More on reddit.com
🌐 r/computerscience
36
46
January 11, 2025
Radix sort vs quicksort. Which one is faster for int arrays? (benchmark with C/Java code)
With fixed size integers things are not so clear cut anymore. While it's true that radix sort takes time linear in N if the number come from a fixed range, the constant factor depends on the range. ... Consider the algorithmic complexity of a bubble sort of no more than 1 trillion entries. More on reddit.com
🌐 r/programming
96
75
April 27, 2011
Time complexity of sorting an array and then searching
I’m trying to understand why the Time complexity is O(nlogn) instead of O(n+logn) or O(n). For a comparison-based sorting algorithm, the best you can do is O(n log n). There are algorithms that can get down to O(n), but they only work for specific kinds of data or require things like fully parallel computation to work. If you were using one of these O(n) algorithms, you'd know it. They're seldom available as a choice, and even when they are, they're never the default. So your process performs an O(n log n) operation followed by an O(n) operation. The O(n log n) operation dominates, so that's the complexity of the process. The iteration is a minor timesink compared to the sorting. More on reddit.com
🌐 r/learnprogramming
4
0
May 25, 2022
🌐
GeeksforGeeks
geeksforgeeks.org › python › sort-in-python
sort() in Python - GeeksforGeeks
Understanding the difference between sorted() and sort() helps you choose the right tool for your needs. Both sort elements but differ in memory usage, stability, and compatibility. Let’s break it down in the following table. ... Python difference between the sorted() and sort() function.
Published   January 13, 2026
🌐
Python
wiki.python.org › moin › TimeComplexity
TimeComplexity
As seen in the source code the complexities for set difference s-t or s.difference(t) (set_difference()) and in-place set difference s.difference_update(t) (set_difference_update_internal()) are different! The first one is O(len(s)) (for every element in s add it to the new set, if not in t).
🌐
GeeksforGeeks
geeksforgeeks.org › python › fastest-way-to-sort-in-python
Fastest Way to Sort in Python - GeeksforGeeks
July 23, 2025 - Time Complexity: O(n^2) Selection Sort: Simple and intuitive but inefficient for large datasets.
Find elsewhere
🌐
Medium
medium.com › @nickshpilevoy › sorting-algorithms-time-complexity-comparison-a4285365f02f
Sorting Algorithms: An Overview of Time Complexities | by Nikita Shpilevoy | Medium
September 28, 2024 - Time Complexity: O(n log n) in worst-case, O(n) for nearly sorted data. Why it’s effective: Timsort is a hybrid sorting algorithm derived from Mergesort and Insertion sort. It’s optimized for real-world data patterns like partially sorted data.
🌐
Educative
educative.io › answers › what-is-the-python-list-sort
What is the Python list sort()?
The Python list sort() has been using the Timsort algorithm since version 2.3. This algorithm has a runtime complexity of O(n.logn).
🌐
Medium
leapcell.medium.com › why-pythons-sort-is-faster-than-you-think-bac6c2d28836
Why Python’s Sort Is Faster Than You Think 🐍🐍 | by Leapcell | Medium
February 1, 2025 - Like other merge sorts, Timesrot is a stable sorting algorithm, and the worst — case time complexity is O(n log n). In the worst case, the Timsort algorithm requires temporary space of n/2, and in the best case, it only requires a very small ...
🌐
DEV Community
dev.to › nkpydev › part-6-sorting-algorithms-in-python-concepts-code-and-complexity-ii4
Part 6: Sorting Algorithms in Python – Concepts, Code, and Complexity - DEV Community
April 4, 2025 - def insertion_sort(arr): for i in range(1, len(arr)): key = arr[i] j = i - 1 while j >= 0 and arr[j] > key: arr[j + 1] = arr[j] j -= 1 arr[j + 1] = key return arr · 📦 Time: O(n²), but efficient for small or nearly sorted arrays
🌐
Medium
medium.com › @bhargavacharanreddy › do-you-know-the-time-complexity-of-pythons-sorted-function-1ae9e7d712b1
Do you know the time complexity of Python’s Sorted() function? - Charan - Medium
February 1, 2022 - Do you know the time complexity of Python’s Sorted() function? print(sorted([5,4,3,2,1])) [1, 2, 3, 4, 5] Developers who are working on Python might have used the sorted function in their code at …
🌐
pythonlib
pythonlib.ru › en › post69
Python sort algorithms: Introduction and examples
Worst-case time complexity: O(n²) - when the pivot element is always the minimum or maximum. [ O(n^2) ] Space complexity: O(log n) - for recursive calls. [ O(\log n) ] Merge sort also uses the "divide and conquer" principle.
🌐
Quora
quora.com › What-is-the-time-complexity-of-the-Python-built-in-sorted-function
What is the time complexity of the Python built-in sorted function? - Quora
Answer (1 of 5): {n}\log_{2}{n}. As others have mentioned, the built-in sorting algorithm of Python uses a special version of merge sort, called Timsort, which runs in {n}\log_{2}{n} time.
🌐
GeeksforGeeks
geeksforgeeks.org › dsa › time-and-space-complexity-analysis-of-selection-sort
Time and Space complexity analysis of Selection Sort - GeeksforGeeks
July 23, 2025 - DSA Python · Last Updated : 23 Jul, 2025 · The Selection sort algorithm has a time complexity of O(n^2) and a space complexity of O(1) since it does not require any additional memory space apart from a temporary variable used for swapping.
🌐
Instagram
instagram.com › p › DXHRnVWEfZr
These questions have rejected more people than JEE ever ...
April 15, 2026 - We cannot provide a description for this page right now
🌐
TutorialsPoint
tutorialspoint.com › python_data_structure › python_sorting_algorithms.htm
Python - Sorting Algorithms
Shell Sort involves sorting elements which are away from each other. We sort a large sublist of a given list and go on reducing the size of the list until all elements are sorted. The below program finds the gap by equating it to half of the length of the list size and then starts sorting all elements in it.
🌐
Real Python
realpython.com › sorting-algorithms-python
Sorting Algorithms in Python – Real Python
November 27, 2023 - O(n), then, is the best-case runtime complexity of bubble sort. But keep in mind that best cases are an exception, and you should focus on the average case when comparing different algorithms.
🌐
Wikipedia
en.wikipedia.org › wiki › In-place_algorithm
In-place algorithm - Wikipedia
1 month ago - More broadly, in-place means that the algorithm does not use extra space for manipulating the input but may require a small though non-constant extra space for its operation. Usually, this space is O(log n), though sometimes anything in o(n) is allowed. Note that space complexity also has varied ...