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 is more efficient? By how much?
- Can a list be reverted to the unsorted state after
list.sort()
has been performed?