>>> ut
[<Tag: 128>, <Tag: 2008>, <Tag: <>, <Tag: actionscript>, <Tag: addresses>, <Tag: aes>, <Tag: ajax> ...]
>>> ut[1].count
1L
When we have the same list, ut,
I'd like to sort the list down based on the attribute count
of the element of ut.
What function should I use?
sorting python count
ut.sort(key=lambda x: x.count, reverse=True)
newlist = sorted(ut, key=lambda x: x.count, reverse=True)
For more information on sorting using keys, see here
© 2024 OneMinuteCode. All rights reserved.