Ciao a tutti, devo ordinare un dizionario in base al nome. Ho provato, cercando sul web, OrderedDict dovrebbe essere quello che fa al caso mio.
import collections diz = [{'add': '10', 'name': 'ccc', 'pwd': '12'}, {'add': '11', 'name': 'aaa', 'pwd': '45'}, {'add': '12', 'name': 'bbb', 'pwd': '79'}] print (collections.OrderedDict(sorted(diz.items(), key=lambda t: t[1]))) ma mi viene restituito un errore AttributeError: 'list' object has no attribute 'items' E' come se diz venisse visto come lista e non come dizionario. Dove sbaglio? Grazie Marcello
_______________________________________________ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python