Re: ZTK 2.0: Deprecate zope.sequencesort
Arfrever Frehtes Taifersar Arahesis <[email protected]>
| Newsgroups | gmane.comp.web.zope.devel |
|---|---|
| Message-ID | <[email protected]> |
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 <[email protected]> > > 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 _______________________________________________ Zope-Dev maillist - [email protected] https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )
signature.asc
(application/pgp-signature, 836 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (GNU/Linux) iQIcBAABCgAGBQJRMQ9WAAoJEMyxswy68gDO7fUP/2QOqevWt2vKsVVcVoPfCz+4 tL/kwjbVyFxOKbGaDNbctg1xRAG2YEfMfS7zyi++2ijentOUvnE1a3sTQAh+XM6z AVfn6Jwbb6iU+Us5t/SgDC8JIm9+SVqe5Ra/D3p0wSPpkmGL98OcHFkFLnpigK+d lqc3bCG290XsOFY6NBC4QjBZ/cBS3tHGDRJjj3vzJJWqlQn23WIK6lNyeOZNM+k1 3QQvpMxMQL93QS4yj7yLAoyoIHzhMnxhsfGOKE5YipoaCrsk7IauCoEQMTVsMpWy AkkzMa8mR58trJ+2WbFhRkC1n/5m9dQYEUmj2VB8aDontGqA66vNE0R5T5YqhKVb Dskj3yR/riyOqbuca3IkX9rCrInegmymmanjoJwBstyGS+uwaa47qmNgVo+nCwZR OMI9UP8rKNC/87ypFHZrLLJBGCw1eYFFllQnd+vcvzvJpjpcbfcsnC87EC18FOdx 00iyveOzsstScaauufL5FLcCQD7uVOCmC9a4BHZ1ggPD9O9IA0c8NvvaEJSDX/no 2CdsuOcS7aEatjmasEI5jYKCVff3xMUtchcAEdYCxJtjIUzPAkkMz4B+KCvjXvwX ETLUebIZvEaOOs42h+sWhOpEYn4r3P0F013iiLWFfpAzrvRoaVHp0i395gZSmNPm nWB8UHc/KdWyUoKfRo61 =TB2S -----END PGP SIGNATURE-----