Sorting two dimentional array by column?
paddy3118 at googlemail.com
Thu Jul 3 00:09:39 CEST 2008
On Jul 2, 10:35 pm, Tobiah <t... at tobiah.org> 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.
> ** Posted fromhttp://www.teranews.com**
key = lambda dictinarray: dictinarray.get(sortkeyname)
More information about the Python-list