MemotivaSequences and slicing

What is the difference between sort and sorted?

Sequences and slicing

Audio flashcard · 0:12

Nortren·

What is the difference between sort and sorted?

0:12

The sort method is defined on lists and sorts the list in place, returning None. The sorted built-in function takes any iterable and returns a new sorted list, leaving the original unchanged. Both accept a key function and a reverse flag.
docs.python.org