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
๐ŸŒ
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.
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
What is the time complexity of Python sorted()? - TestMu AI Community
What is the Python sort time complexity of the sorted() function? I have a list of lists and I am sorting them using the following: data = sorted(data, key=itemgetter(0)) I was wondering what is the runtime complexity of this Python function? More on community.testmu.ai
๐ŸŒ community.testmu.ai
0
December 19, 2024
python - What is the time complexity of the following function, that uses buit-in sorted function? - Stack Overflow
Stack Overflow chat opening up to all users in January; Stack Exchange chat... 2 What is the algorithmic complexity of this sorting function? 100 What is the complexity of the sorted() function? 2 What's the time complexity for the following python function? More on stackoverflow.com
๐ŸŒ stackoverflow.com
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.. a=[3,7,1,0,2,8] a.sort() print a What are the worst, average and best cases of such programs in case of sorting ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ fastest-way-to-sort-in-python
Fastest Way to Sort in Python - GeeksforGeeks
July 23, 2025 - It is the default sorting algorithm ... original list in sorted order. It uses Timsort algorithm which has a time complexity of O(n log n) in the worst case....
๐ŸŒ
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 ...
๐ŸŒ
Educative
educative.io โ€บ answers โ€บ what-is-the-python-list-sort
What is the Python list sort()?
The sort() function is a member of the list data structure in Python. By default, it sorts the elements of a list in ascending order. ... In the case of strings and characters, sorting is done based on their ASCII values. The Python list sort() has been using the Timsort algorithm since version 2.3. This algorithm has a runtime complexity of O(n.logn).
Find elsewhere
๐ŸŒ
iO Flood
ioflood.com โ€บ blog โ€บ python-sort-algorithms
Python Sort Algorithms: A Comprehensive Guide
February 6, 2024 - In the context of Python sort algorithms, the built-in sort() and sorted() functions have a time complexity of O(n log n) due to their use of Timsort, a highly efficient sorting algorithm.
๐ŸŒ
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.
๐ŸŒ
PrepBytes
prepbytes.com โ€บ home โ€บ python โ€บ sort function in python
Sort() Function in Python
July 13, 2023 - If reverse is True, the list will be sorted in descending order. Otherwise, it will be sorted in ascending order. Python sort() function time complexity is O(n log n) for average and worst cases.
๐ŸŒ
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 - It builds a max-heap (or min-heap) from the list and repeatedly extracts the maximum (or minimum) element, resulting in a sorted list. Heap Sort has a time complexity of O(n log n) and is efficient for large datasets.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ sort-in-python
sort() in Python - GeeksforGeeks
The sort() method in Python is used to arrange the elements of a list in a specific order.
Published ย  January 13, 2026
๐ŸŒ
Real Python
realpython.com โ€บ sorting-algorithms-python
Sorting Algorithms in Python โ€“ Real Python
November 27, 2023 - This tutorial covers two different ... theoretical perspective, youโ€™ll measure the runtime complexity of the algorithms using Big O notation....
๐ŸŒ
Stack Abuse
stackabuse.com โ€บ sorting-algorithms-in-python
Sorting Algorithms in Python
October 24, 2023 - Visualize a binary tree with 3 elements, it has a height of 2. Now visualize a binary tree with 7 elements, it has a height of 3. The tree grows logarithmically to n. The heapify function traverses that tree in \(O(log(n))\) time. The heap_sort function iterates over the array \(n\) times. Therefore the overall time complexity of the Heap Sort algorithm is \(O(nlog(n))\).
๐ŸŒ
TestMu AI Community
community.testmu.ai โ€บ ask a question
What is the time complexity of Python sorted()? - TestMu AI Community
December 19, 2024 - What is the Python sort time complexity of the sorted() function? I have a list of lists and I am sorting them using the following: data = sorted(data, key=itemgetter(0)) I was wondering what is the runtime complexityโ€ฆ
๐ŸŒ
PrepBytes
prepbytes.com โ€บ home โ€บ python โ€บ python sorted function
Python Sorted() Function
November 1, 2023 - For example, you can sort a list of employees by their last name and then by their first name. Sorting by key function: The sorted() function can be used to sort data based on a custom key function. This is useful for sorting data based on complex rules or for sorting data that cannot be easily sorted using built-in Python functions.
๐ŸŒ
AmbitionBox
ambitionbox.com โ€บ interviews โ€บ question โ€บ what-is-the-time-complexity-of-the-sort-function-in-python-bgnNYGTj6
What is the time complexity of the .sort() function in Python?
Prepare for your next job interview with AmbitionBox. Read 12 Lakh+ interview questions & answers shared by real candidates across 1 Lakh+ companies in India.