On Jul 2, 10:35 pm, Tobiah <[EMAIL PROTECTED]> wrote: > > Imagine an excel spreadsheet. I can choose > > a column and sort the records based on the items > > in that column. I would like to do the same > > thing with a large two dimensional array. > > What would be the fastest way (in computation time) > > to accomplish this? > > Now that I think about the problem more, I really want > to sort an array of dictionaries according one of the > keys of each. Could I use: > > array.sort(key = something) > > Where something looks at the proper item in the > current row? I can't quite visualize how to pull > the item out of the dictionary. > > Thanks > > ** Posted fromhttp://www.teranews.com**
Hi Tobiah, Try this: arrayofdicts.sort( key = lambda dictinarray: dictinarray.get(sortkeyname) ) - Paddy. -- http://mail.python.org/mailman/listinfo/python-list