Example 1: python sort list in reverse
list.sort(reverse=True)
sorted(list, reverse=True)
Example 2: python sort list
vowels = ['e', 'a', 'u', 'o', 'i']
vowels.sort()
sortedVowels = sorted(vowels)
Example 3: sort array python
array = [1, 2, 3, 19, 11, 90, 0]
array.sort()
print(array)
Example 4: python sort
>>> student_tuples = [
... ('john', 'A', 15),
... ('jane', 'B', 12),
... ('dave', 'B', 10),
... ]
>>> sorted(student_tuples, key=lambda student: student[2])
[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]
Example 5: sort an array python
myList = [1,5,3,4]
myList.sort()
print(myList)
Example 6: sort python
>>> x = [1 ,11, 2, 3]
>>> y = sorted(x)
>>> x
[1, 11, 2, 3]
>>> y
[1, 2, 3, 11]