>
> The "key" function passed to the Python sorted() function should take only 
>> a single argument -- an element from the iterator being sorted. If your 
>> mycmp requires two arguments, then it should fail with sorted() as well as 
>> with Rows.sort(). Just rewrite mycmp so it takes only one argument (a Row 
>> object).
>>
>
> Ah, the "key" argument.  That's what's going on.  sorted() has both a cmp 
> and key argument, and I viewed this as a cmp problem.
>

Yeah, "key" is preferred since Python 2.4, and that is what Rows.sort() 
uses internally. 
See 
https://docs.python.org/2/howto/sorting.html#the-old-way-using-the-cmp-parameter.
 
If you need that same mycmp function elsewhere so cannot simply rewrite to 
work as the "key" argument, you can use functools.cmp_to_key() to convert 
it to a "key" function.

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to