This is interesting, but beware... you are abusing sort's magic $a and $b variables. Even strict wouldn't complain, but you could have problems if the $code includes a sort.
Also don't use local there, use my. Its faster, and there is no reason to use local in this scenario.