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.

Syntax

  • 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

 

 

 


Comments