python - How to alphabetically sort array of dictionaries on single key? -


i want sort list of friends returned facebook's graph api. result after sorting needs alphabetical order of friends name.

[       {          "name": "joe smith",          "id": "6500000"       },       {          "name": "andrew smith",          "id": "82000"       },       {          "name": "dora smith",          "id": "97000000"       },       {          "name": "jacki smith",          "id": "107000"       } ] 

additional notes: running on google app engine, uses python 2.5.x.

if list called a, can sort way using:

a.sort(cmp = lambda x,y: cmp(x["name"],y["name"]))


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -