[Zope] Sorting rows from a database in reverse order

Martijn Pieters mj@antraciet.nl
Thu, 23 Sep 1999 13:31:58 +0200


At 22:43 22/09/99 , Ben Glazer wrote:
>1. Will dtml-in always iterate over the rows display_news returns in order?

It will iterate over the list in the order it received it. If your wuery 
returns them in order, they will be displayed in order.

>2. If so, is there a way for dtml-in to reverse the sort order?

Yes, just add the 'reverse' attribute to your in tag:

   <dtml-in display_news sort=date reverse>
     <a href="<dtml-var url>"><dtml-var headline></a><br>
     <dtml-var date>
     <br><br>
   </dtml-in>

>3. If so, is it more efficient to let Zope or MySQL sort the data?

Depends on the length of the returned set, but if you indexed your tables 
properly, the DB will be faster.

--
Martijn Pieters, Web Developer
| Antraciet http://www.antraciet.nl
| Tel: +31-35-7502100 Fax: +31-35-7502111
| mailto:mj@antraciet.nl http://www.antraciet.nl/~mj
| PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149
------------------------------------------