list.sort() is not assignable as anything other than
None. It is an in-place operation so doesn’t need to be assigned. However, the original list is mutated in the process, of course.
Python has a function in the built-ins that will copy a list, then sort it, then assign it.
sorted_cities = sorted(cities)
See the differences? One of them is that the original list is not mutated.
Number two is that it is assignable. The iterable that we passed in to the function is cast to a list, sorted and returned as a list.
>>> a = 9,3,8,1,5,7,4,2,6
(1, 2, 3, 4, 5, 6, 7, 8, 9)
If it is iterable, it is sortable. Just takes some steps, is all.
>>> a = 'aquickbrownfoxjumpsoverthelazydog'
('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z')
>>> b = 'a a quick brown fox fox jumps over the the lazy dog'
('a', 'brown', 'dog', 'fox', 'jumps', 'lazy', 'over', 'quick', 'the')