Re: multidimensional insertion order



it_says_BALLS_on_your forehead wrote:
a "hacky" way to do it would be to initialize a counter to 1, and
prepend the counter and an underscore to your key.

then you could sort key on the hash. if the actual key itself is
important (i.e. you need this to be retained) you can take it out
afterwards, using regexs, substr, etc...depending on if you have a
fixed width counter (e.g. 0001, 0002), or not. regex would be s/\d+_//;

hope that helps!

Thanks, I might try that.
Caleb
.



Relevant Pages

  • Re: multidimensional insertion order
    ... a "hacky" way to do it would be to initialize a counter to 1, ... prepend the counter and an underscore to your key. ...
    (comp.lang.perl.misc)
  • Re: Fastest way to find a match?
    ... Thanks everyone for your thoughtful posts. ... The OP was psuedocode and ... What about using a hash table? ... underscore, so just check the hash table for the existence of "foo2". ...
    (comp.lang.perl.misc)
  • Re: Preserve order in a HoH
    ... On Fri, 2005-03-11 at 15:26 +1100, Harald Ashburner wrote: ... > essentially a hash of hash of hash of hash etc. ... > (note ugly hacks like prepend the order to the key aren't going to cut ...
    (perl.beginners)
  • Re: Preserve order in a HoH
    ... Preserve order in a HoH ... > essentially a hash of hash of hash of hash etc. ... > (note ugly hacks like prepend the order to the key aren't going to cut ...
    (perl.beginners)
  • Re: Change link color on div hover
    ... I prepend the timestamp to the key and it have been working fine for ... var _hash =; ...
    (comp.lang.javascript)