No inplace sort

list.sort() changes the order of the input list, which is surprising. Use the sorted() bulitin which doesn't do this.