Solution:
I have faced the same Problem in the recent past. I have the following solution on your problem.
Depending on the contents of list, there different approaches and they can be used according to need. In the easiest possible case, when the play_list is considered the list of integers or strings, the sorted() function must be used as follows:
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 the contents of play_list are complex objects e.g. lists or class object the key parameter must be specified that will be used for comparisons as follows:
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']]
So I will suggest the following approaches:
1) If the elements are atomic, then you can use sorted(play_list);
2) If the elements are complex, then you can use sorted(play_list, key=key)