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
🌐
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 - This sorted function is based on the Time sort algorithm which was created by Tim peters. This particular soring algorithm is a hybrid sorting algorithm based on insertion and mergesort algorithms internally. This is really fascinating. Following are the time and space complexities of this ...
Discussions

sorting - What is the space complexity of the python sort? - Stack Overflow
What space complexity does the python sort take? I can't find any definitive documentation on this anywhere ... Space complexity is defined as how much additional space the algorithm needs in terms of the N elements. More on stackoverflow.com
🌐 stackoverflow.com
What is the time complexity of the .sort() function in Python?
Python's .sort() uses Timsort with O(n log n) average and worst-case time complexity, and O(n) best-case for nearly sorted data. Timsort is a hybrid sorting algorithm derived from merge sort and insert...read more More on ambitionbox.com
🌐 ambitionbox.com
1
Sorting lists in python: sorted() vs sort()
sorted() is functional and .sort() is an instance method. Functions should preferably not modify input parameters while object method would be expected to modify act on the instance. Edit: I know that my statement doesn't hold true in all instances, but when making your own functions and methods it's a good way to implement it like described. Documentation is key as always. More on reddit.com
🌐 r/Python
32
904
May 16, 2022
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
🌐
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.
🌐
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 › 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.
🌐
Stack Abuse
stackabuse.com › sorting-algorithms-in-python
Sorting Algorithms in Python
October 24, 2023 - Therefore the average time complexity of the Quick Sort algorithm is \(O(nlog(n))\). While it's beneficial to understand these sorting algorithms, in most Python projects you would probably use the sort functions already provided in the language.
🌐
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
Find elsewhere
🌐
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 - In the above example, the given unordered list is sorted in the reverse order using the function “ sort( reverse = True ) ”. Time Complexity is the amount of time taken by the computer to run a particular algorithm.
🌐
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.
🌐
iO Flood
ioflood.com › blog › python-sort-algorithms
Python Sort Algorithms: A Comprehensive Guide
February 6, 2024 - Heapsort’s time complexity is O(n log n) in all cases, and it sorts in place, meaning it doesn’t require extra space. However, it’s not a stable sort, meaning equal elements may not keep their original order.
🌐
CodeSignal
codesignal.com › learn › courses › sorting-and-searching-algorithms-in-python › lessons › mastering-quick-sort-implementation-and-complexity-analysis-in-python
Mastering Quick Sort: Implementation and Complexity ...
For Quick Sort, the time complexity can be described as ... O(n^2)O(n2) for the worst-case scenario. The worst-case scenario arises when the pivot divides the array predominantly into one large sub-array and one small sub-array instead of equal halves. However, the efficient partitioning scheme ...
🌐
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 time complexity of sorting algorithms can vary significantly, ranging from O(n^2) for Bubble Sort, Selection Sort, and Insertion Sort, to O(n log n) for Merge Sort, Quick Sort, Heap Sort, and Shell Sort, and even O(nk) for Radix Sort.
🌐
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 ...
🌐
Medium
dipankarmedh1.medium.com › sorting-algorithms-in-python-1afb97238099
Mastering Sorting Algorithms with Python: A Comprehensive Guide for Data Scientists and Developers | by Dipankar Medhi | Medium
February 21, 2023 - Merge sort has a time complexity of O(n log n). Quick sort is a divide-and-conquer algorithm that sorts an array by choosing a “pivot” element and partitioning the other elements into two sub-arrays, according to whether they are less than ...
🌐
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 ...
🌐
Readthedocs
python-textbok.readthedocs.io › en › 1.0 › Sorting_and_Searching_Algorithms.html
Sorting, searching and algorithm analysis — Object-Oriented Programming in Python 1 documentation
Here are the best case, expected and worst case costs for the sorting and searching algorithms we have discussed so far: What does O(1) mean? It means that the cost of an algorithm is constant, no matter what the value of N is. For both these search algorithms, the best case scenario happens when the first element to be tested is the correct element – then we only have to perform a single operation to find it. In the previous table, big O notation has been used to describe the time complexity of 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).
🌐
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(V + E) because the algorithm only visits each vertex and edge once.
🌐
AmbitionBox
ambitionbox.com › home › interviews › interview questions
What is the time complexity of the .sort() function in Pytho - AmbitionBox
Python's .sort() uses Timsort with O(n log n) average and worst-case time complexity, and O(n) best-case for nearly sorted data. Timsort is a hybrid sorting algorithm derived from merge sort and insert...read more