logo-MindMajix
PostPythonPython
J
James ROBERT

Posted on 16th June 2024|27 views

0
votes

Python Sort Objects By Attribute

How can I sort a list of objects based on the attribute of that object?

1 answers
Answers
P
Lakshmi sowjanya

Posted on 16th June 2024| views

Try this

 

ut.sort(key=lambda y: y.count, reverse=True) 

 

newlist = sorted(ut, key=lambda y: y.count, reverse=True)

 

Write your answer

STILL GOT QUERIES?

Get a Live FREE Demo

  • Explore the trending and niche courses and learning maps
  • Learn about tuition fee, payment plans, and scholarships
  • Get access to webinars and self-paced learning videos
Name
Course *
Email *
Phone Number