CBSE Class 11 Computer Science
Question 64 of 104
List Manipulation — Question 17
Back to all questions 17
Question Question 17
What is the difference between sort( ) and sorted( )?
Answer
| sort( ) | sorted( ) |
|---|---|
| It modifies the list it is called on. That is, the sorted list is stored in the same list; a new list is not created. | It creates a new list containing a sorted version of the list passed to it as argument. It does not modify the list passed as a parameter. |
| It works on a list and modifies it. | It can take any iterable sequence type, such as a list or a tuple etc, and it always returns a sorted list irrespective of the type of sequence passed to it. |
| It does not return anything (no return value). It modifies the list in place. | It returns a newly created sorted list. It does not change the passed sequence. |