Sort List Alphanumerically
List objects have a
method that will sort the list alphanumerically, ascending, by default:
sort()
Example
Sort the list alphabetically:
thislist = ["orange", "mango", "kiwi", "pineapple", "banana"]
thislist.sort()
print(thislist)
Example
Sort the list numerically:
thislist = [100, 50, 65, 82, 23]
thislist.sort()
print(thislist)
Sort Descending
To sort descending, use the keyword argument reverse = True
: Continue reading Python – Sort Lists