 |
intoK Apprentice
Joined: 18 Feb 2007 Posts: 190
|
Posted: Thu Oct 09, 2008 7:38 pm
auto-sorted record variables |
some of my scripts rely on "inner code" that is written in record variables, order of such is very important for their intended function
in zmud, when adding key to var new key was always added at the bottom, it was also possible to manually rearrange that order in settings editor
now in cmud, they get autosorted in some sort of order even without sorted box checked, also editor dosnt allow for rearrangement.
very disappointing, downgrade from zmud capabilities. |
|
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Thu Oct 09, 2008 8:09 pm |
You can't sort data record variables; they're hashed in CMUD, same as in practically every other programming language, which means that the name of the key has nothing to do with its position in the internal table. This was done because it gives a gigantic speed increase when accessing these variables, especially for very large variables.
Any time you used the sorting of data record variables in the past, it should be possible to code something that'll do the same thing using slightly different techniques. If you explain what your specific issue is, we can suggest something. |
|
|
|
 |
intoK Apprentice
Joined: 18 Feb 2007 Posts: 190
|
Posted: Thu Oct 09, 2008 8:56 pm |
umm, apparently clicking sorted checkbox does exactly that - sorts record var alphabetically. #loopdb @recvar {#SA %key} gives repeateable results on _both_ (sorted/unsorted) cases
which means semi-random sorting is sorting after all, also, changing keyname in "unsorted" var repositions the key |
|
|
|
 |
intoK Apprentice
Joined: 18 Feb 2007 Posts: 190
|
Posted: Mon Oct 13, 2008 2:33 pm |
another thought, sorting hash table is trivial, since you are only rewriting indexes, actually reordering of record var in zmud must have required massive amounts of memory access, i find i hard to believe that they werent hashed in zmud, altho zmud does uses massive amounts of memory...
|
|
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Mon Oct 13, 2008 4:44 pm |
The #SORT command will also sort a string list or record variable by alphabetical key order. Custom sort orders is on the list for the future.
zMUD definitely did *not* hash the record (or stringlist) variables, which is why CMUD is so much faster than zMUD in many cases. |
|
|
|
 |
intoK Apprentice
Joined: 18 Feb 2007 Posts: 190
|
Posted: Mon Oct 13, 2008 4:48 pm |
cheers for the reply, id really wish there was way to have it sorted by creation order, especially now that pop works with records
|
|
|
|
 |
ReedN Wizard
Joined: 04 Jan 2006 Posts: 1279 Location: Portland, Oregon
|
Posted: Mon Oct 13, 2008 9:14 pm |
Any reason why you are trying to arm twist hash tables into this role instead of just using a list? Lists are inherently order specific, perhaps it might work better.
|
|
|
|
 |
intoK Apprentice
Joined: 18 Feb 2007 Posts: 190
|
Posted: Mon Oct 13, 2008 10:16 pm |
1st, theres no arm twisting involved, since by design hash table is easiest construction for sorting
2nd, i explained in first post
but, if you kindly provide me with a way to, for simple example, remove b and d if a present, if not remove b and if d present remove f and so on, then absolutely
cant really discuss specifics, but that was very simplified example
for now im contemplating use of list to reference proper order in record - ugly and impacts performance tho |
|
|
|
 |
intoK Apprentice
Joined: 18 Feb 2007 Posts: 190
|
Posted: Mon Oct 13, 2008 10:22 pm |
actually just google expression tree
|
|
|
|
 |
|
|
|