How to sort a list in Python using Sort() function? - #Python Tutorials

How to sort List in Python?

How to sort list elements using Sort and Sorted function in #Python?

To sort a list in Python, you can use Sort and Sorted methods about which you will learn in this video.

Also, you will learn how to create a blank list in python.


primarylist = [] #To create a blank list
#Below code will sort the numbers using both sorted and sort methods
primarylist = [1,3,4,2,9,4,6,3]
#Below code will sort the strings using both sorted and sort methods
secondarylist = ['a','v','b','f','c']
print("Original list:",secondarylist)
print("Using Sorted():",sorted(secondarylist))
print("Original list:",secondarylist)
print("Using the sort function",secondarylist)