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

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
Complexity of Python Sort Method - Stack Overflow
If I have to sort some list, say a, using the sort method in Python such as below.. ... What are the worst, average and best cases of such programs in case of sorting ? And what complexities would they have in each ? More on stackoverflow.com
🌐 stackoverflow.com
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
Radix sort vs quicksort. Which one is faster for int arrays? (benchmark with C/Java code)
For smaller arrays, quicksort should be faster, for larger arrays, radix sort. The crossover point depends on implementation details. More on reddit.com
🌐 r/programming
96
75
April 27, 2011
🌐
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.
🌐
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.
🌐
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).
🌐
Python documentation
docs.python.org › 3 › howto › sorting.html
Sorting Techniques — Python 3.14.4 documentation
February 23, 2026 - The standard library provides several tools that do less work than a full sort: min() and max() return the smallest and largest values, respectively. These functions make a single pass over the input data and require almost no auxiliary memory. heapq.nsmallest() and heapq.nlargest() return the n smallest and largest values, respectively. These functions make a single pass over the data keeping only n elements in memory at a time.
🌐
GeeksforGeeks
geeksforgeeks.org › dsa › time-and-space-complexity-analysis-of-bubble-sort
Time and Space Complexity Analysis of Bubble Sort - GeeksforGeeks
July 23, 2025 - DSA Python · Last Updated : 23 Jul, 2025 · The time complexity of Bubble Sort is O(n^2) in the worst-case scenario and the space complexity of Bubble sort is O(1). Bubble Sort only needs a constant amount of additional space during the sorting ...
🌐
Quora
quora.com › Is-Python-sorted-slow
Is Python sorted slow? - Quora
But compared to a Prius Prime, whose 0–60 time is a torpid 12.2 seconds, it’s lightning fast. So “slow” is relative, but I find the Volt to be fast (or perhaps more correctly “quick”) compared to most cars in its class, and other drivers are often surprised at how quickly the gap between us opens up… · OK, so let’s take a look at sorted(), using it to sort 1,000,000 integers: $ python3 -m timeit 'import random; sorted(random.randint(1, 1_000_000) for _ in range(1_000_000))'
🌐
YouTube
youtube.com › playlist
Strivers A2Z-DSA Course | DSA Playlist | Placements - YouTube
This playlist is not in C++ or Java or Python, it covers DSA and we write pseudocode, only one video is in C++, for the basics, but apart from that we cover ...
🌐
University of Maryland
math.umd.edu › ~immortal › CMSC351
CMSC351: Notes
These notes are works in progress This will probably be the list for Fall 2023. Non-clickables are those which need to be created · A small Python package containing simple functions to execute commands on Coinbase via the API. Use these at your own risk once you have an API key since they ...
🌐
CP-Algorithms
cp-algorithms.com › data_structures › segment_tree.html
Segment Tree - Algorithms for Competitive Programming
In the root node we do a binary search, and in all other nodes we only do constant work. This means the complexity for answering a query is $O(\log n)$. But notice, that this uses three times more memory than a normal Merge Sort Tree, which already uses a lot of memory ($O(n \log n)$).
🌐
Programiz PRO
programiz.pro › resources › dsa-python-topological-sort-complexity
Exploring Time Complexity of Topological Sort Algorithm in Python
December 23, 2024 - So, it has a time complexity of O(E). 2. Initializing the Queue with Vertices Having Indegree 0 · This step involves iterating over the vertices, which takes time proportional to the number of vertices V. So, it has a time complexity of O(V).
🌐
Built In
builtin.com › machine-learning › fastest-sorting-algorithm
Sorting Algorithms: Slowest to Fastest | Built In
Hence the total time complexity is O(n log n). Since we are recursively calling the MergeSort function, an internal stack is used to store these function calls. There will be at most n calls in the stack, and hence, the space complexity will ...
🌐
Programiz PRO
programiz.pro › resources › dsa-counting-sort-complexity
Exploring Time and Space Complexities of Counting Sort
December 20, 2024 - So, regardless of the distribution of values, the total time complexity is O(n + k). Comparing the Number of Operations Required for Different Input Sizes · Counting sort requires two main arrays: the count array and the output array.