-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 02/28/2013 01:04 PM, Stephan Richter wrote:
On Thursday, February 28, 2013 11:32:26 AM Tres Seaver wrote:
Thoughts?
I'm generally in favor of shrinking the ZTK, but just for discussion's sake: emulating 'cmp' for objects which have rich comparison semantics isn't that difficult::
def _faux_cmp(lhs, rhs): return int(rhs < lhs) - int(lhs < rhs)
Well, that is the obvious implementation of cmp(), but that's not the point of the package. The package provides a callable class that represents a cmp() function. The problem is that it is not just creating some keys and calls cmp() on it. I could not find out a way to create a single key.
The main export of the package is the 'sort' function, which takes a sequence, per-column sort specs (key/attr name, sort function, direction), and optional extra data (e.g., the DTML namespace) and a flag indicating whether to use key or attribute lookup. The 'SortBy' class is really just an implementation detail of that API.
I guess the right way to port the package is to implement a sort API.
I have ported it to Python 3.2 and 3.3 and released a 4.0.0 version. Tres. - -- =================================================================== Tres Seaver +1 540-429-0999 tseaver@palladion.com Palladion Software "Excellence by Design" http://palladion.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with undefined - http://www.enigmail.net/ iEYEARECAAYFAlEvuFEACgkQ+gerLs4ltQ7+0wCg1gdpKIzx1Q1lvS0xVWAhSRIM wPsAniwipqErV4yMTkRDr5GxBz6GJfzW =6SHn -----END PGP SIGNATURE-----