1# Basic syntax:
2your_list.sort()
3
4# Example usage:
5your_list = [42, 17, 23, 111]
6your_list.sort()
7print(your_list)
8--> [17, 23, 42, 111]
9
10# If you have a list of numbers that are of type string, you can do the
11# following to sort them numerically without first converting to type
12# int. E.g.:
13your_list = ['42', '17', '23', '111']
14your_list.sort(key=int)
15print(your_list)
16--> ['17', '23', '42', '111']
17
18# If you want to sort a list of strings in place based on a number
19# that is consistently located at some position in the strings, use
20# a lambda function. E.g.:
21your_list =['cmd1','cmd10', 'cmd111', 'cmd50', 'cmd99']
22your_list.sort(key=lambda x: int(x[3:]))
23print(your_list)
24--> ['cmd1', 'cmd10', 'cmd50', 'cmd99', 'cmd111']
25
26# If you don't want to sort the list in place, used sorted. E.g.:
27your_list = [42, 17, 23, 111]
28your_list_sorted = sorted(your_list)
29print(your_list_sorted)
30--> [17, 23, 42, 111]