![]() |
|
Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re: Re: hash sort problemsby dmmiller2k (Chaplain) |
on Apr 19, 2002 at 13:53 UTC ( #160537=note: print w/replies, xml ) | Need Help?? |
For the sort of sorting (um, sorry) you seem to want to do, treat a {tag} value of 53 as an arbitrary 'high' value and anything else as an arbitrary 'low' value (i.e., just have two) for one level of sorting, and then append to that the sorting you're already doing. To wit:
Of course, with a large number of items, this manner of sorting is beau coup inefficient; you may want to precalculate the keys, a la the Schwartzian Transform (or dare I suggest the Advanced Sorting - GRT - Guttman Rosler Transform?). In this case, the precalculated keys might consist of the various components appended together: Update: Admittedly, pack would be far more efficient than sprintf in the following, but I wanted to illustrate the point without obfuscating it any more than necessary.
Similarly, your other criteria (looks like {tag} is contained within the {ADMINS} key, whatever that means) might be incorporated by changing the bi-valued key to a tri-valued key (0, 1, 2) and inserting that criteria between the two existing ones.
Hope this helps. dmm If you GIVE a man a fish you feed him for a dayBut, TEACH him to fish and you feed him for a lifetime
In Section
Seekers of Perl Wisdom
|
|