On Wed, Sep 16, 2009 at 11:45 AM, Igor Mavrović - ma...@irb <igor.mavro...@irb.hr> wrote: > Sorry Kent, I should have put it in the original message... > This is the way I call the sorted function: > > # resultSet looks like: [[("DN", {"":["", ...], ...})], ...] > > resultSetSortedByCn = sorted(resultSet, key=lambda x:(x[0][1]["sn"], > x[0][1]["givenName"])) > resultSetSortedByOu = sorted(resultSet, key=lambda x:(x[0][1]["ou"], > x[0][1]["sn"], x[0][1]["givenName"])) > > I have to use it like this for obvious reasons (sort by org-unit, surname > and then name). Therefore Rich's suggestion: > > print sorted(words, key=lambda o: locale.strxfrm(o[0])) > > can't work 'cause strxfrm's argument must be a string, not a tuple...
How about this (assuming both arguments need to be transformed)? key=lambda x:(locale.strxfrm(x[0][1]["sn"]), locale.strxfrm(x[0][1]["givenName"])) Kent _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor