[Zope-dev] ZTK 2.0: Deprecate zope.sequencesort
Arfrever Frehtes Taifersar Arahesis
arfrever.fta at gmail.com
Fri Mar 1 20:28:04 UTC 2013
2013-03-01 04:04:07 Tres Seaver napisał(a):
> On 02/28/2013 10:00 PM, Lennart Regebro wrote:
> > On Thu, Feb 28, 2013 at 5:33 PM, Tres Seaver <tseaver at palladion.com>
> > wrote:
> >> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
> >>
> >> On 02/28/2013 10:41 AM, Lennart Regebro wrote:
> >>
> >>> Reading through the code, it seems to use a lot of code to provide
> >>> quite basic sorting functionality. It feels like it's trying to
> >>> fill the same role as sorted() does since Python 2.4.
> >>
> >> The other features (locale-aware sorting, sort different keys using
> >> different algorithms / directions) are not easy to emulate using
> >> 'sorted()'
> >
> > Locale aware sorting can be tricky, I'll have to look at that code
> > again. Sorting different keys and directions are trivial with
> > sorted(). I'm not sure what different "algorithms" mean, with sorted
> > you implement a function that returns a sorting key, that sorting key
> > is then used to sort. It should be possible to sort according to any
> > algorithm that way.
>
> Assuming an unsorted list of news stories, how would you use sorted to
> get them ordered by category (ascending) + publication date (descending)?
sorted(news_stories, key=lambda x: (x.category, -x.publication_date))
--
Arfrever Frehtes Taifersar Arahesis
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.zope.org/pipermail/zope-dev/attachments/20130301/9f5be350/attachment.sig>
More information about the Zope-Dev
mailing list