Solution:
Depending on the contents of list, different approaches should be used. In easiest possible case, when play_list is list of integers or strings, sorted() function should be used:
play_list = [3, 1, 2, 5, 4]
sorted_play_list = sorted(play_list)
print(sorted_play_list) # [1, 2, 3, 4, 5]
#----------------------------------------
play_list = ['cdgf', 'fs', 'aa', 'Zsdf', 'qvtr', 'fa']
sorted_play_list = sorted(play_list)
print(sorted_play_list) # ['Zsdf', 'aa', 'cdgf', 'fa', 'fs', 'qvtr']
If contents of play_list are complex objects (like lists or class object), the key parameter should specified, which will be used for comparisons:
play_list = [[2, 'b'],[1, 'c'],[3, 'a']]
# sort by second element of nettled list
sorted_play_list = sorted(play_list, key=lambda a: a[1])
print(sorted_play_list) # [[3, 'a'], [2, 'b'], [1, 'c']]
Explanation:
Sorting is ordering a list of objects. We can distinguish two types of sorting. If the number of objects is small enough to fits into the main memory, sorting is called internal sorting. To sort the whole table, select the table. Move the pointer over the letter above the column by which you want to sort. Click the arrow that appears, then choose a sorting option: Sort Ascending: Sort the data in alphabetical order (A to Z) or by increasing numerical values.