[Zope] SQL list sorting

Tim Zegir trzegir at ncable.net.au
Wed Jan 21 17:37:14 EST 2004


On Thu, 2004-01-22 at 06:53, Dieter Maurer wrote:
> Tim Zegir wrote at 2004-1-21 16:04 +1100:
> >I have 2 sqlmethods foo and bar
> >
> >then i have a python script 
> >
> >-----------------------
> >x=int(myx)
> >mylist=[]
> >
> >for result in context.foo:
this should be for result in context.foo():
and yes it does work
> Are you sure, this does work?
> 
>   You say above "foo" is an Z SQL Method.
>   A Z SQL Method is not a sequence and your cannot iterated over it.
>   You must apply it to get a sequence as result.
> 
> > ...
> >what i want to do is sort this list by a field
> >eg. mylist.sort('fieldname')
> 
> You want to look at the "sequence.sort" documentation...
I've tryed google many times searching for sequence.sort and while
returning results I cant seem to find anything explaining how to use it.

Any by trial and error i have come up with the following.
---------
sequence.sort(mylist, ('name'))
---------
this does not produce an error but also does not sort the list.
btw if i try
sequence.sort(mylist, ('name', 'description'))
i get
"sort option must contains no more than 2 fields"

thanks for the help so far
-- 
-tim zegir




More information about the Zope mailing list