You're very close to understanding the main trick.
The way the sort works is the source of any unportability. I'm relying on the way sort is implemented, so if the internals of sort were altered from one Perl version to another it'll break my sort.
As far as %v, that's dark pink, and you can cut down the mightiest tree in the forest with it. The other closure, however, is important.