Hello! I returned to the idea after spending some time with bugs in b2; all was fixed in b3 at last. I am ready to start coding and patching dtml-in. On Wed, 14 Mar 2001, Dieter Maurer wrote:
I am not yet clear about a good syntax. It should be something, that pairs the attribute with the sorting function essential for this attribute: something like:
sort="attr1[cmp1],attr2,attr3[cmp3],...."
This should mean, use "cmp1" for "attr1", the default comparison for "attr2" (i.e. cmp) and "cmp3" for "attr3" (and so on).
Each "cmp" is looked up in the namespace and if not found there, in a standard set of comparison function, such that it is easy to get "locale_asc", "locale_desc", "case_insensitive_asc", ....
As I already said, this looks good... but I don't want to have a predefined set of names. I want these "locale_asc"/"locale_desc" to be the real functions. And I don't want to have 2 almost identical functions (asc/desc) for every comparison function. So I am thinking about syntax like this: sort="attr1/cmp1,attr2,attr3/cmp3/desc,...." That is, attribute/function/direction. Default direction is ASC, of course. It would be easy to modify the generic function you've provided:
def lexicographicCompare(values1,values2,functions): '''*values1*, *values2* and *functions* are all tuples of the same length with "functions[i]" capable of comparing "value1[i]" and "values2[i]". The result is the lexicographic comparison of the tuples.''' for v1,v2,cmp in map(None,value1,value2,functions): c= cmp(v1,v2) # maybe we should do something, if this raises an exception if c: return c return 0
Oleg. ---- Oleg Broytmann http://www.zope.org/Members/phd/ phd@phd.pp.ru Programmers don't die, they just GOSUB without RETURN.