On Fri, Mar 1, 2013 at 4:04 AM, Tres Seaver <tsea...@palladion.com> wrote:
> Assuming an unsorted list of news stories, how would you use sorted to
> get them ordered by category (ascending) + publication date (descending)?
This is the easiest, most obvious way:
sorted(sorted(news_stories, lambda x: x.publication_date,
reverse=True), lambda x: x.category)
And yes, I have made performance analysis, and it is often faster two
do two sorts than trying to compute a complex key.
> If you spend more than a minute on it (e.g., trying to come up with a
> bug-free way to compute "negative dates") you've proved my mpoint. :)
I haven't got a clue what "negative dates" are, unless you mean BC.
But the above works (unless I got ascending and descending mixed up as
Zope-Dev maillist - Zope-Dev@zope.org
** No cross posts or HTML encoding! **
(Related lists -