sorted() returns a new sorted list, leaving the original list unaffected. list.sort() sorts the list in-place, mutating the list indices, and returns None (like all in-place operations).

sorted() works on any iterable, not just lists. Strings, tuples, dictionaries (you'll get the keys), generators, etc., returning a list containing all elements, sorted.

  • Use list.sort() when you want to mutate the list, sorted() when you want a new sorted object back. Use sorted() when you want to sort something that is an iterable, not a list yet.

  • For lists, list.sort() is faster than sorted() because it doesn't have to create a copy. For any other iterable, you have no choice.

  • No, you cannot retrieve the original positions. Once you called list.sort() the original order is gone.

Answer from Martijn Pieters on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-difference-between-sorted-and-sort
Python - Difference between sorted() and sort() - GeeksforGeeks
July 12, 2025 - sort() in Python function is very similar to sorted() but unlike sorted it returns nothing and makes changes to the original sequence.
Discussions

python - What is the difference between sorted(list) vs list.sort()? - Stack Overflow
list.sort() sorts the list and replaces the original list, whereas sorted(list) returns a sorted copy of the list, without changing the original list. When is one preferred over the other? Which i... More on stackoverflow.com
🌐 stackoverflow.com
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
sorted() vs sort()
That’s the thing. sort doesn’t return anything. You’re comparing None to a list. There’s nothing to compare there. You need to sort first then compare numbers == sorted(numbers). More on reddit.com
🌐 r/learnpython
15
4
February 28, 2025
min() vs 'sort() and then list[0]'

As others have mentioned, min will be quicker. min just has to walk through the list once, whereas sort must do more compares, making it more complex.

However, one case you might want to use sort is when you need more than just the minimum. Eg. you want the 5 smallest items, not just the smallest. Here "sorted(mylist)[:5]" will do the job, but another option to keep in mind is the heapq module, as "heapq.nsmallest(5, mylist)" will often perform better than sort, at least for a small number of items.

More on reddit.com
🌐 r/Python
36
29
February 23, 2012
🌐
Enki
enki.com › post › what-s-the-difference-between-sort-and-sorted-in-python-dcb0b
Enki | Blog - What’s the difference between Sort and Sorted in Python
The sorted() function excels when you need to create a new sorted list without modifying the original data. It’s perfect for scenarios where data integrity is non-negotiable and you need a reliable, unaltered copy of your data. Python's versatility extends beyond just lists; its sorting capabilities can be applied to various data structures, including tuples and dictionaries.
Top answer
1 of 7
445

sorted() returns a new sorted list, leaving the original list unaffected. list.sort() sorts the list in-place, mutating the list indices, and returns None (like all in-place operations).

sorted() works on any iterable, not just lists. Strings, tuples, dictionaries (you'll get the keys), generators, etc., returning a list containing all elements, sorted.

  • Use list.sort() when you want to mutate the list, sorted() when you want a new sorted object back. Use sorted() when you want to sort something that is an iterable, not a list yet.

  • For lists, list.sort() is faster than sorted() because it doesn't have to create a copy. For any other iterable, you have no choice.

  • No, you cannot retrieve the original positions. Once you called list.sort() the original order is gone.

2 of 7
69

What is the difference between sorted(list) vs list.sort()?

  • list.sort mutates the list in-place & returns None
  • sorted takes any iterable & returns a new list, sorted.

sorted is equivalent to this Python implementation, but the CPython builtin function should run measurably faster as it is written in C:

def sorted(iterable, key=None):
    new_list = list(iterable)    # make a new list
    new_list.sort(key=key)       # sort it
    return new_list              # return it

When is one preferred over the other?

  • Use list.sort when you do not wish to retain the original sort order (Thus you will be able to reuse the list in-place in memory.) and when you are the sole owner of the list (if the list is shared by other code and you mutate it, you could introduce bugs where that list is used.)
  • Use sorted when you want to retain the original sort order or when you wish to create a new list that only your local code owns.

Can a list be reverted to the unsorted state after list.sort() has been performed?

No - unless you made a copy yourself, that information is lost because the sort is done in-place.

Which is more efficient? By how much?

To illustrate the penalty of creating a new list, use the timeit module, here's our setup:

import timeit
setup = """
import random
lists = [list(range(10000)) for _ in range(1000)]  # list of lists
for l in lists:
    random.shuffle(l) # shuffle each list
shuffled_iter = iter(lists) # wrap as iterator so next() yields one at a time
"""

And here's our results for a list of randomly arranged 10000 integers, as we can see here, we've disproven an older list creation expense myth:

Python 2.7

>>> timeit.repeat("next(shuffled_iter).sort()", setup=setup, number = 1000)
[3.75168503401801, 3.7473005310166627, 3.753129180986434]
>>> timeit.repeat("sorted(next(shuffled_iter))", setup=setup, number = 1000)
[3.702025591977872, 3.709248117986135, 3.71071034099441]

Python 3

>>> timeit.repeat("next(shuffled_iter).sort()", setup=setup, number = 1000)
[2.797430992126465, 2.796825885772705, 2.7744789123535156]
>>> timeit.repeat("sorted(next(shuffled_iter))", setup=setup, number = 1000)
[2.675589084625244, 2.8019039630889893, 2.849375009536743]

After some feedback, I decided another test would be desirable with different characteristics. Here I provide the same randomly ordered list of 100,000 in length for each iteration 1,000 times.

import timeit
setup = """
import random
random.seed(0)
lst = list(range(100000))
random.shuffle(lst)
"""

I interpret this larger sort's difference coming from the copying mentioned by Martijn, but it does not dominate to the point stated in the older more popular answer here, here the increase in time is only about 10%

>>> timeit.repeat("lst[:].sort()", setup=setup, number = 10000)
[572.919036605, 573.1384446719999, 568.5923951]
>>> timeit.repeat("sorted(lst[:])", setup=setup, number = 10000)
[647.0584738299999, 653.4040515829997, 657.9457361929999]

I also ran the above on a much smaller sort, and saw that the new sorted copy version still takes about 2% longer running time on a sort of 1000 length.

Poke ran his own code as well, here's the code:

setup = '''
import random
random.seed(12122353453462456)
lst = list(range({length}))
random.shuffle(lst)
lists = [lst[:] for _ in range({repeats})]
it = iter(lists)
'''
t1 = 'l = next(it); l.sort()'
t2 = 'l = next(it); sorted(l)'
length = 10 ** 7
repeats = 10 ** 2
print(length, repeats)
for t in t1, t2:
    print(t)
    print(timeit(t, setup=setup.format(length=length, repeats=repeats), number=repeats))

He found for 1000000 length sort, (ran 100 times) a similar result, but only about a 5% increase in time, here's the output:

10000000 100
l = next(it); l.sort()
610.5015971539542
l = next(it); sorted(l)
646.7786222379655

Conclusion:

A large sized list being sorted with sorted making a copy will likely dominate differences, but the sorting itself dominates the operation, and organizing your code around these differences would be premature optimization. I would use sorted when I need a new sorted list of the data, and I would use list.sort when I need to sort a list in-place, and let that determine my usage.

🌐
Fatos Morina
fatosmorina.com › home › the difference between sort() and sorted() in python
The Difference Between sort() and sorted() in Python - Fatos Morina
October 2, 2022 - As a recap, the difference between sort() and sorted() is that sort() modifies the existing list, whereas sorted() returns a new sorted list.
🌐
McGill University
cs.mcgill.ca › ~akroit › math › compsci › Cormen Introduction to Algorithms.pdf pdf
A L G O R I T H M S I N T R O D U C T I O N T O T H I R D E D I T I O N
Python lacks repeat-until loops, and its for loops operate a little differently from the for loops in · this book. 2.1 · Insertion sort · 21 · counter in each iteration, and we use the keyword downto when a for loop · decrements its loop counter. When the loop counter changes by an amount ·
Find elsewhere
🌐
Python
docs.python.org › 3 › library › heapq.html
heapq — Heap queue algorithm
The latter two functions perform best for smaller values of n. For larger values, it is more efficient to use the sorted() function. Also, when n==1, it is more efficient to use the built-in min() and max() functions.
🌐
Quora
quora.com › What-is-the-difference-between-list-sort-vs-sorted-list-in-Python
What is the difference between list.sort() vs. sorted (list) in Python? - Quora
Answer (1 of 7): I always use these as the way to explain the difference between a function and a method. sorted() is a built-in function that takes any iterable (list, tuple, dict, string, etc.) and returns a new list containing all of the items from that iterable in sorted order: [code]>>> so...
🌐
Mimo
mimo.org › glossary › python › list-sort()
Python List sort(): Master Data Sorting | Learn Now
The sort() method modifies a list in place. However, there's a built-in function that creates and returns a sorted list instead. Using sorted(), a special sort function in Python, the original list remains the same.
🌐
Afternerd
afternerd.com › blog › sort-vs-sorted
Python: Sort vs Sorted - Afternerd
August 6, 2020 - In Python, you can use sort or sorted to sort a list.
🌐
Medium
medium.com › @ufs2k19 › sort-vs-sorted-why-python-gave-us-two-ways-to-tidy-chaos-1b651897857a
sort() vs sorted(): Why Python Gave Us Two Ways to Tidy Chaos | by Umar Faruk Sarkar | Medium
September 3, 2025 - Sorting is simply the process of putting a list of items into a particular order, such as arranging numbers from smallest to largest or words alphabetically. This is done by comparing the items with each other to figure out where each one should go in the list. The rules for comparing items help decide how everything will be ordered in the end. When Python gives you two tools that sound almost the same — sort() and sorted()—it’s tempting to assume they’re twins.
🌐
PREP INSTA
prepinsta.com › home › python tutorial › difference between sort() and sorted() in python
Difference between Sort() and sorted() in Python | PrepInsta
September 20, 2023 - The difference between the sort() function and the sorted() function in python is that the sort function will modify the list it is called on
🌐
Pierian Training
pieriantraining.com › home › python list sorting: sort() and sorted()
Python List Sorting: sort() and sorted() - Pierian Training
June 18, 2023 - However, for larger lists or more complex sorting needs we might want to explore other alternatives such as sorted(), which we will cover in another blog post. Python provides a built-in function called `sorted()` that can be used to sort lists. This function returns a new sorted list and does not modify the original list.
🌐
Real Python
realpython.com › python-sort
How to Use sorted() and .sort() in Python – Real Python
February 24, 2025 - Just like before, you can use sorted() to iterate through each element of the iterable you pass in. In a string, each element means each character, including spaces. Note: Python sorts strings lexicographically by comparing Unicode code points of the individual characters from left to right.
🌐
DEV Community
dev.to › trinityyi › what-is-the-difference-between-listsort-and-sorted-in-python-5a6g
What is the difference between list.sort() and sorted() in Python? - DEV Community
September 23, 2022 - Python provides two ways to sort a list, the built-in list method list.sort() and the built-in function sorted().
🌐
Admin's Choice
adminschoice.com › python-sort-or-sorted-which-one-to-chose-for-your-program
python sort() or sorted()- which one to chose for your program ? - Admin's Choice
October 1, 2023 - Sorting functions are essential tools for data manipulation and set of rules in computer programming languages like python.
🌐
Programiz
programiz.com › python-programming › methods › built-in › sorted
Python sorted()
The sorted() method sorts the elements of the given iterable in ascending order and returns it. In this tutorial, we will learn about the Python sorted() function with the help of examples.
🌐
Substack
futuredigestnews.substack.com › p › claude-code-changed-everything-heres
Claude Code Changed Everything — Here’s How I Use It (And I Don’t Write Code)
2 weeks ago - “Scan every PDF in this folder, extract the client name, invoice amount, currency and payment date, rename each file as YYYY-MM-DD_ClientName_Amount, sort them into monthly subfolders, and export a summary spreadsheet.”
🌐
Big-O Cheat Sheet
bigocheatsheet.com
Big-O Algorithm Complexity Cheat Sheet (Know Thy Complexities!) @ericdrowell
This webpage covers the space and time Big-O complexities of common algorithms used in Computer Science. When preparing for technical interviews in the past, I found myself spending hours crawling the internet putting together the best, average, and worst case complexities for search and sorting ...
🌐
VisuAlgo
visualgo.net › en › sorting
Sorting (Bubble, Selection, Insertion, Merge, Quick, Counting, Radix) - VisuAlgo
std::partial_sort (most likely Binary Heap) in STL algorithm. In Python, you can use · sort (most likely a hybrid sorting algorithm: Timsort). In Java, you can use · Collections.sort. In OCaml, you can use · List.sort compare list_name. If the comparison function is problem-specific, we may need to supply additional comparison function to those built-in sorting routines.