[Zope] What If i don't want Zope sorting for me.

Harry Wilkinson harryw@nipltd.com
Mon, 25 Feb 2002 15:02:49 +0000


I don't know about the internals of how dictionaries are implemented, but I 
would guess that there is some degree of hashing in it.  Dictionaries are 
orderless, they don't have any concept of an order in them.  The keys are 
probably hashed and stored in a convenient order so that lookup times are a 
minimal as possible.  They are stored in whatever order makes the dictionary 
work most efficiently.

If you want to store some ordering information, I think you'll have to keep 
information on that somewhere else.  You might want to use a sequence of 
dictionary keys, since sequences are ordered.


Harry

On Monday 25 February 2002 2:36 pm, Terry wrote:
> Dear List,
>
> I have a dictionary in REQUEST.
>
> <dtml-call "REQUEST.set('my_dic',{'ar_id':'Article
> ID','ar_head':'Head','ar_body':'Body'})"> <dtml-var "my_dic.keys()">
>
> Zope will sort for me. How to use the original order ?
>
> Thanks in advance
>
> Terry