views:

258

answers:

2

in my django view, if i import operator, and use the following code:

multitags = sorted(multitags, key=operator.attrgetter('date_added'))

is there an easy way to reverse the order – such that i get the dates in descending order (today at top; last week underneath)?

+5  A: 

This should work:

sorted(multitags, key=operator.attrgetter('date_added'), reverse=True)

This document on the python wiki is worth reading through at least once to get an idea of other things worth knowing:

ars
you guys rock! thanks much.
+1  A: 

Sure, just add reverse=True to the keyword arguments with which you're calling .sorted!

Alex Martelli
you guys rock! thank you Alex.