...searching for natural sort
Thanks! I had not heard that term before. That will be very useful.
Though I'm a little curious why your integer indices are used to index a hash not an array.
That's a really good question & embarassingly, I have no good technical answer. I suspect it is both because this is recycled code that I'm reworking to handle a larger data set, and the original keys were not integers; and because I work with hashes so much more than arrays that it's just a more comfortable method for me.
Thanks for pointing that out - I will re-think how I'm handling this data structure.
Update:After dinking around with this a bit: The integer index is an important key into other data structures (it's an ifIndex, if you are familiar with SNMP MIB-II). This was not obvious from my small example, sorry. The indices are not always sequential - often a few (or several, gah!) are missing here and there. For me, it's clearer (and therefore easier to maintain) to think of the integer as a hash key. Trying to work with an array for that was a very interesting exercise, thanks. :)
In reply to Re^2: best practices for a complex sort + splitting an alphanumeric string (natural)
by gabrielle
in thread best practices for a complex sort + splitting an alphanumeric string
by gabrielle
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |