|
Sir5er Beginner
Joined: 21 Aug 2009 Posts: 11
|
Posted: Fri Feb 19, 2010 5:07 am
How do i stop Database Variables sorting? |
This script:
Quote: |
#VAR TestDb ""
#ADDKEY TestDb O=D
#ADDKEY TestDb M=C
#ADDKEY TestDb C=J
#ADDKEY TestDb Z=D
|
Produces:
C=J|M=C|O=D|Z=D
But i want:
O=D|M=C|C=J|Z=D
How do i get this to happen? Auto-sort is turned off in the variable view. |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Fri Feb 19, 2010 6:06 am |
You can't. Datarecord variables are stored using a hash table, so there's no way to maintain any particular order.
|
|
_________________ EDIT: I didn't like my old signature |
|
|
|
Sir5er Beginner
Joined: 21 Aug 2009 Posts: 11
|
Posted: Fri Feb 19, 2010 6:14 am |
Well can i have an alternative for a database variable then?
|
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Fri Feb 19, 2010 2:37 pm |
The first question I would ask is, are you certain you need it to be in order? Often it is not necessary if you rethink your algorithm.
If you decide you do want to keep things in order, the usual way is to have a second variable which is a string list containing your keys in the order you want them. This would mean a process for adding to or deleting from the string list whenever you add or delete a key in your database variable. |
|
|
|
|
|