[Zope] Help! Sorting on a numeric id?

Oleg Broytmann Oleg Broytmann <phd@phd.pp.ru>
Thu, 13 Dec 2001 12:23:48 +0300


On Wed, Dec 12, 2001 at 06:58:26PM -0800, Mats Nordgren wrote:
> How do i sort on numeric id?
> 
> I have a Folder containing Zclasses with numeric ids.
> what i am trying to do is to sort it, but it treats
> the ids as strings as it should, how do i sort it so
> it treats the ids as numeric values?
> 
> <dtml-in "objectValues(['ZClass'])" sort=id>
> <dtml-var id>
> </dtml-in>
> 
> Produces:
> 1
> 10

   In the ZClass create a method, say "num_id", that will return numeric
id. Something like "return int(self.id)". Sort by the method.

<dtml-in "objectValues(['ZClass'])" sort=num_id> or
<dtml-in "objectValues(['ZClass'])" expr_sort=num_id>.

Oleg.
-- 
     Oleg Broytmann            http://phd.pp.ru/            phd@phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.