Message51873
The motivation for this patch was to be able to chain together operator.itemgetter objects so that I could sort a list of items that have the form ((a,b), c) by the 'a' or 'b' part of the item.
Sorting by 'b' can be accomplished with:
l.sort(key=compose(itemgetter(1), itemgetter(0)))
compose(itemgetter(1), itemgetter(0)) is equivalent to
def c(v):
return itemgetter(1)(itemgetter(0)(v)) |
|
Date |
User |
Action |
Args |
2007-08-23 15:56:34 | admin | link | issue1660179 messages |
2007-08-23 15:56:34 | admin | create | |
|