in reply to Notation of sort function

Is there a case in which we would specify something else for $a than for $b?

No.

And worse, you're calculating that value n * log2(n) * 2 times.

Sort::Key and related modules provide an interface where the key is only calculated n times.