the = sign was a typo that is not present in my original code - sorry about that, same with the print statement - was just to indicate that there was some output.
The solution was indeed to use sort with just $a and $b - yep, Perl is not my first language.
Thank you all for the exceptionally quick replies.
Ole C.