Python dictionaries do not preserve order. In Python 2.7, you can use an
ordered dictionary:
http://docs.python.org/dev/library/collections.html#collections.OrderedDict.
Anyway, if you're using SQLFORM, you can use the 'fields' argument to
provide a list of fields to be included in the form -- they will be
displayed in the same order as the list.
Anthony
On Friday, June 24, 2011 7:37:01 AM UTC-4, David J wrote:
> I tried making a dict
> user_info = {'username':'Username','password':'Password'}
> billing_info =
> {'field_name':'Label','street':'Street','city':'City','state':'State',etc..}
>
>
> when I display it seems the dict does not keep the order?
>
> So when I display billing it shows some random order like state, street,
> city
>
> which is clearly not the order I specified in the dict; Perhaps the dict
> object does not maintain ordering?
>
> Anyone have a suggestion on how to display form fields in a specified
> order other than manually creating the form?
>
> The reason I am doing this is so that I can show on one page 2 forms and
> separate them
>
> for instance
>
> User Info
>
>
> BIlling Info
>
>