Site menu

CodeCook.io

  • Languages
    • C
    • C++
    • CSS
    • Git
    • HTML
    • Java
    • JavaScript
    • jQuery
    • PHP
    • Python
    • Ruby
    • Scala
  • object
  • sort

Python - Sort objects by function

Sort a list of objects by ordering of a function of that object.

0
535
  • Share on Facebook
  • Share on Google+
  • Share on Twitter
sorted({{list}}, key=lambda obj: obj.{{func_name}})
python

Notes

last update: Oct. 23, 2014

Advertisement

This project is hosted on DigitalOcean, try it and support us

Related concept

  • Sort list of numbers
  • Class definition
  • Object instantiation
  • Class function
  • Object inner function

Random task

  • Transform scale
  • Add user
  • Resolve merge conflict with remote file
  • Get public IP address
  • Transform rotate
  • Blog
  • About
  • License