I\'ve got a list of Python objects that I\'d like to sort by an attribute of the objects themselves. The list looks like:
>>> ut [,
# To sort the list in place... ut.sort(key=lambda x: x.count, reverse=True) # To return a new list, use the sorted() built-in function... newlist = sorted(ut, key=lambda x: x.count, reverse=True)
More on sorting by keys.