[Zope-dev] Re: [Zope] Sorting a list
RC Compaan writes: I have a list: mylist=[('R',31),('I',80),('A',80),('S',23),('E',35),('C',21)] I want to rebuild the list sorted from high to low on the sequence-item. When i call dtml-in mylist sort=sequence-item reverse the list gets sorted on the sequence-key not the sequence-item. As I understand the alphabetical characters are the sequence-keys and the float values are the sequence-items. Where do misunderstand? What you see is caused by the following code in "DocumentTemplate.DT_In.InClass.__init__": if has_key('sort'): self.sort=sort=args['sort'] if sort=='sequence-item': self.sort='' This means, "dtml-in sort=sequence-item" does not sort by "sequence-item" but by the complete tuple (key,item). I think, the special treatment of lists of pairs is altogether a slight misfeature. It would probably have been better to use a special "dict" attribute in analogy to the "mapping" attribute to call for the special pair interpretation. 'sequence-item' should then still be the complete item and 'sequence-value' the second pair component. Probably, it is too late by now to change this. Dieter ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope] Sorting a list
RC Compaan writes: I have a list: mylist=[('R',31),('I',80),('A',80),('S',23),('E',35),('C',21)] I want to rebuild the list sorted from high to low on the sequence-item. When i call dtml-in mylist sort=sequence-item reverse the list gets sorted on the sequence-key not the sequence-item. As I understand the alphabetical characters are the sequence-keys and the float values are the sequence-items. Where do misunderstand? What you see is caused by the following code in "DocumentTemplate.DT_In.InClass.__init__": if has_key('sort'): self.sort=sort=args['sort'] if sort=='sequence-item': self.sort='' This means, "dtml-in sort=sequence-item" does not sort by "sequence-item" but by the complete tuple (key,item). I think, the special treatment of lists of pairs is altogether a slight misfeature. It would probably have been better to use a special "dict" attribute in analogy to the "mapping" attribute to call for the special pair interpretation. 'sequence-item' should then still be the complete item and 'sequence-value' the second pair component. Probably, it is too late by now to change this. Dieter ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
[Zope] Sorting a list
I have a list: mylist=[('R',31),('I',80),('A',80),('S',23),('E',35),('C',21)] I want to rebuild the list sorted from high to low on the sequence-item. When i call dtml-in mylist sort=sequence-item reverse the list gets sorted on the sequence-key not the sequence-item. As I understand the alphabetical characters are the sequence-keys and the float values are the sequence-items. Where do misunderstand? Roché ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
[Zope] Sorting a list descending using dtml-in
Hello, if I'm iterating over a list using the dtml-in tag, is it then possible to sort the items descending? Pieter Pieter Claerhout Application Support - CreoScitex Europe ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
RE: [Zope] Sorting a list descending using dtml-in
Seems to work fine in Zope 2.1.6... Pieter -Original Message- From: Jerome Alet [mailto:[EMAIL PROTECTED]] Sent: Tuesday, July 04, 2000 3:48 PM To: Pieter Claerhout Cc: '[EMAIL PROTECTED]' Subject: Re: [Zope] Sorting a list descending using dtml-in On Tue, 4 Jul 2000, Pieter Claerhout wrote: if I'm iterating over a list using the dtml-in tag, is it then possible to sort the items descending? IIRC: !-- UNTESTED -- dtml-in mylist sort=id reverse /dtml-in bye, Jerome ALET - [EMAIL PROTECTED] - http://cortex.unice.fr/~jerome Faculte de Medecine de Nice - http://noe.unice.fr - Tel: 04 93 37 76 30 28 Avenue de Valombrose - 06107 NICE Cedex 2 - FRANCE ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )