less than 1 minute read

The Python language, like many other high-level programming languages, offers the ability to sort data out of the box using sort(). You can use to sort any list as long as the values inside are comparable.

Example:

list = ["1", "9", "0", "9", "5"]
list = [int(i) for i in list]
list.sort()
print (list)

# Output:
[0, 1, 5, 9, 9]

Additional information

sort() is a method of list class and can only be used with lists.

References

Sort() and sorted()

Sorting Data With Python - Course

Different kinds of sorting algorithm

Difference between sorted() and sort()