>>>>> "c" == ccc31807 <> writes:
c> I would like to make this observation -- Learning how to sort on
c> the various elements of a multi-level data structure isn't obvious,
c> and isn't particularly easy, and the know-how probably isn't that
c> common, but it's a very useful thing to learn. I'm not real good at
c> it, but I've figured out the basics enough to do what I need to
c> do. We occasionally have code walk-throughs with people who don't
c> use Perl (I'm essentially the only Perl guy in the shop) and I've
c> learned to expect and appreciate the WTF reaction every time we hit
c> the unwinding of a multi-level hash, with the sort block a little
c> extra piece of lunacy. It's nice being able to see order in what
c> everyone else perceives as chaos.
try Sort::Maker and see how it generates sorts. you can print out
generated source and cut/paste it into your code. it is much easier to
define how to get and compare keys in its syntax than the basic sort
when you do multilevel and complex key extraction. also it can generate
sorts in 4 styles including plain (which you did) and the fastest one
GRT.
the issue about accessing the hash ref from inside the sorter is still
a problem but you could eval the generated code in the current
context and it should have access to any lexicals. not tested yet.
uri
--
Uri Guttman ------
--------
http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ----
http://bestfriendscocoa.com ---------