arrange print results by size + python code example
Example 1: sort a list by length python
#Input
def sort():
lst = [orange, ant, phone, banana, notebook)
lst2 = sorted(lst, key=len)
return lst2
#Output : [ant, phone, banana, orange, notebook)
Example 2: how to store sorted list into new variable in python
>>> numbers = [6, 9, 3, 1]
>>> numbers_sorted = sorted(numbers)
>>> numbers_sorted
[1, 3, 6, 9]
>>> numbers
[6, 9, 3, 1]