Python Tips

2013/04/07 Python

License: (CC 3.0) BY-NC-SA

  1. sort a dict by value: sorted(d.iteritems(), key=lambda x: x[1])
  2. sort a dict list by a key: l.sort(key=lambda x: x[key])

Search

    Table of Contents