Difference between list.sort() and sorted() in Python
There are 3 main differences between list.sort() and sorted().
What is it?
-
sortis a method of list. -
sortedis a bult-in function.
Suitable object
-
sortis only for lists. -
sortedcan be used for any iterable.
Returns
-
sortsorts the original list in-place and returnsNone. -
sortedreturns a list without modification on the original list.
Reference
Python tools
Share on: