Python List sort () method
description
sort () function is used to sort the list of the original, if the specified parameter, the comparison function specified compare function.
grammar
sort () method syntax:
list.sort([func])
parameter
- func - optional parameter, if the parameter Use this parameter to specify the method to sort.
return value
This method does not return a value, but the target list will be sorted.
Examples
The following example shows the sort () function to use:
#!/usr/bin/python aList = [123, 'xyz', 'zara', 'abc', 'xyz']; aList.sort(); print "List : ", aList;
Examples of the above output results are as follows:
List : [123, 'abc', 'xyz', 'xyz', 'zara']