Newbie: sort list of dictionaries

Sven Brandt no_more_spam at
Tue Dec 30 13:26:27 CET 2003

Hi there,

please excuse for asking such basic questions (I am new to programming, esp. 

I have a list of dictionaries. I want the elements of the list to be sorted by 
the value of a key of the dict .

my_list=[{'title': 'foo', 'id': 5, 'text': 'some text'},
          {'title': 'bar', 'id': 3, 'text': 'my text'},
          {'title': 'bla', 'id': 6, 'text': 'any text'}, ]

my_list.sort("by the id value")

Thanx for help

More information about the Python-list mailing list