发表于 2014-04-09 10:08:22 by 月小升
如果我们将字典放入数组,那么就可以对字典进行排序 dict = [ {'id':'4','name':'b'}, {'id':'6','name':'c'}, {'id':'3','name':'a'}, {'id':'1','name':'g'}, {'id':'8','name':'f'} ] #dict.sort(lambda x,y: cmp(x['id'], y['id'])) dict = s More