Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Sir5er
Beginner


Joined: 21 Aug 2009
Posts: 11

PostPosted: 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.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: 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
Reply with quote
Sir5er
Beginner


Joined: 21 Aug 2009
Posts: 11

PostPosted: Fri Feb 19, 2010 6:14 am   
 
Well can i have an alternative for a database variable then?
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: 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.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net