On Thu, Jan 08, 2004 at 04:11:08PM -0600, Terry Hancock wrote:
On Thursday 08 January 2004 09:56 am, Jaroslav Lukesh wrote:
I want to sort by value of i[0] before "i" is taken to FOR. So it is possible to do something like
for i in self.objectItems('Folder').sort(i[0])
The reason this doesn't work as written is because the .sort() method works in-place and does not return a value. Also, sort needs a function that does the comparison. You want:
values = self.objectItems('Folder') values.sort(lambda a,b: cmp(a[0],b[0]) for i in values: # do stuff pass
sort() is lexicographic by default, which means it already sorts on the first element just fine :-) No comparison function needed in this case. -- Paul Winkler http://www.slinkp.com Look! Up in the sky! It's THE PANTSY NUT! (random hero from isometric.spaceninja.com)