|XP is just a number|
Um, ar0n's actually being nice. You should see him on a bad day.
Normally, your post would have been considered, reaped, and forgotten with no replies to speak of.
However, it's a weekend, so things are a little slow.
In any event, this isn't a place where people solve your problems for you. It's a place where you show them what you've tried and they point out places where you might look for the next step.
I can't speak for ar0n, but I'd probably start by going perldoc -f map and perldoc -f grep.
That done, I might even try perldoc -q sort hash and see if there's anything in the Friendly Manual provided with the language. (There certainly seems to be one or two things that apply. Have you tried them?)
IOW, the Monastery best helps those willing to first help themselves. *That's* why you're getting some insubstantial answers.
For best results, take what you've been given so far, write some code, and then--if still stuck--post what you have and the specific problem you're working through. We'll help you through problems, but we won't do your [home]work for you.