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

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
Using Sort() Vs. Sorted()
a method operates on an object, a function is a standalone thing. in the case of list.sort, the sort method operates on a list instance. typically methods are 'actions' an object can do. pop, append, index are all list methods as they describe things a list can do More on reddit.com
🌐 r/learnpython
3
1
June 7, 2020
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
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.

🌐
Medium
medium.com › @chinthapooja733 › understanding-python-list-sorting-sorted-lst-vs-lst-sort-b10eb98828f7
Understanding Python List Sorting: sorted(lst) vs lst.sort() | by Chinthapooja | Medium
January 20, 2024 - Understanding Python List Sorting: sorted(lst) vs lst.sort() Python provides multiple ways to sort lists, and two common methods are sorted(lst) and lst.sort() . sorted(lst): Creats a New List The …
🌐
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.
🌐
Quora
quora.com › What-is-the-difference-between-sort-and-sorted-function-in-Python
What is the difference between sort() and sorted() function in Python? - Quora
Answer (1 of 5): sort() sorts the original list.sorted returns a sorted list without altering the original list. [code]a = [4,1,23,4,7,8,9] sorted(a) [1, 4, 4, 7, 8, 9, 23] print a [4, 1, 23, 4, 7, 8, 9] a.sort() [1, 4, 4, 7, 8, 9, 23] print ...
Find elsewhere
🌐
freeCodeCamp
freecodecamp.org › news › python-sort-how-to-sort-a-list-in-python
Python .sort() – How to Sort a List in Python
March 8, 2022 - In this article, you will learn how to use Python's sort() list method. You will also learn a different way of performing sorting in Python by using the sorted() function so you can see how it differs from sort(). By the end, you will know the basics...
🌐
Euron
euron.one › community › posts › 1389cab5-bf90-4695-9d56-b757f3aa9448
Sorting in Python: `sorted()` vs `.sort()` - Euron Daily | Euron Community
February 4, 2026 - Hey everyone! 👋 Let's jump into **Module 5: Sorting and Searching Algorithms** and clear up a common point of confusion: `sorted()` vs `.sort()` in Python. ##
🌐
Digital Vidya
digitalvidya.com › blog › data science › a descriptive guide on how to use sorted() and sort() in python
A Descriptive Guide On How To Use Sorted() And Sort() In Python
April 28, 2022 - Every element present in the mixed_numbers has int() called on them for converting them into str values. Then, we can successfully compare every element using the sorted() function and provide a sorted output. Python is capable of converting a value to another data type implicitly.
🌐
Medium
medium.com › @DahlitzF › list-sort-vs-sorted-list-aab92c00e17
list.sort() vs. sorted(list). A closer look at Python’s built-in List… | by Florian Dahlitz | Medium
January 9, 2020 - The previous investigations showed us, that list.sort is slightly faster than sorted and consumes around 24% less memory. However, keep in mind that list.sort is only implemented for lists, whereas sorted accepts any iterable.
🌐
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().
🌐
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.
🌐
Python Engineer
python-engineer.com › posts › sort-vs-sorted
Difference between sort() and sorted() in Python - Python Engineer
March 21, 2022 - Sorting means rearranging a given sequence of elements. ... Python provides two built-in functions which are sort() and sorted(). These two functions are used for sorting but come with a few differences.
🌐
Python documentation
docs.python.org › 3 › howto › sorting.html
Sorting Techniques — Python 3.14.3 documentation
February 23, 2026 - Another difference is that the list.sort() method is only defined for lists. In contrast, the sorted() function accepts any iterable.
🌐
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.
🌐
W3Schools
w3schools.com › python › ref_func_sorted.asp
Python sorted() Function
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Certificate Python Training ... The sorted() function returns a sorted list of the specified iterable object.
🌐
Wikipedia
en.wikipedia.org › wiki › Merge_sort
Merge sort - Wikipedia
4 days ago - In computer science, merge sort (also commonly spelled as mergesort or merge-sort) is an efficient and general purpose comparison-based sorting algorithm. Most implementations of merge sort are stable, which means that the relative order of equal elements is the same between the input and output.
🌐
30 Seconds of Code
30secondsofcode.org › home › python › list.sort vs sorted
What is the difference between list.sort() and sorted() in Python? - 30 seconds of code
June 12, 2021 - list.sort() should be used whenever mutating the list is intended and retrieving the original order of the elements is not desired. On the other hand, sorted() should be used when the object to be sorted is an iterable (e.g. list, tuple, dictionary, ...
🌐
Scaler
scaler.com › home › topics › difference between sort and sorted in python
Difference Between Sort and Sorted in Python - Scaler Topics
October 4, 2023 - The main difference between sort and sorted in Python is that sort function returns nothing and makes changes to the original sequence, while the sorted () function creates a new sequence type containing a sorted version of the given sequence.