Published
- 1 min read
sort list by attribute python
The solution for this is noted below
sort list by attribute python
Solution
# 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)
Try other methods by searching on the site. That is if this doesn’t work