Python List sort() method

The list.sort () method in Python sorts the items of the list in place.

Syntax

Parameter

reverse: If a Boolean value ‘True’ is passed, the  sorting will be done in the descending order else for ‘False’ Boolean value sorting is done in ascending order.

key: This parameter represents a function to specify the sorting criteria(s)

Example 1

Output

Example 2

Output

Example 3

Output

Pin It on Pinterest

Share This