Copyright © tutorialspoint.com

Python List sort() Method

previous next


Description:

This method sorts objects of list, use compare func if given.

Syntax:

list.sort([func])

Parameters:

Here is the detail of parameters:

Return Value:

It returns none but sort the given object from the list.

Example:

#!/usr/bin/python

aList = [123, 'xyz', 'zara', 'abc', 'xyz'];

aList.sort();
print "List : ", aList;

This will produce following result:

List :  [123, 'abc', 'xyz', 'xyz', 'zara']

previous next

Copyright © tutorialspoint.com