Python List sort() Method


Python List sort() Method

  • The sort() method sorts the elements of a given list in a specific order - Ascending or Descending.


  • list.sort(key=..., reverse=...)

Parameter Values

It has two optional parameters.

  • reverse - If true, the sorted list is reversed (or sorted in Descending order) 

  • key - function that serves as a key for the sort comparison




Post a Comment

Post a Comment (0)