Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:

> Without throwing away 500 items:
> 
> def sortt(d):
>     sorted_items = sorted(d.iteritems(),
>                           key=operator.itemgetter(1),
>                           reverse=True)
>     return map(operator.itemgetter(0), sorted_items)

Isn't that just equivalent to:

def sortt(d):
    return sorted(d.iterkeys(), key=d.__getitem__,
                 reverse=True)

which has the advantage of not building a list of tuples just to throw it 
away?
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to