Kindly be informed that the sorted() function will return a new sorted list, leaving the original list unchanged. Whereas the list.sort() will sort the list in-place, mutating the list indices, and returns None (like all in-place operations).
sorted() works on any iterable, not just lists. When you want to mutate the list, you can work with list.sort(), use sorted() when you want a new sorted object back. Use sorted() when you want to sort something that is iterable, not a list yet.
One more interesting thing is that the 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 the list.sort() the original order is gone.
For the best of career growth, check out Intellipaat’s Python online Course and get certified!