shemp,
This is also how Tie::Hash::Sorted is able to dynamically change the sort routine. It can even sort via lexicals that the package normally wouldn't even be able to see via closures. If you could deal with your hash being tied, Tie::Hash::Sorted gives you the ability to define your sort routine at runtime for free.