in reply to Perl sorting unique values

There is the perldoc tool installed with your Perl, and also the perlfaq online. Searching for your keywords yields good explanations of how to do things:

> perldoc -q unique

How can I get the unique keys from two hashes?
How can I remove duplicate elements from a list or array?

> perldoc -q sort

How do I sort an array by (anything)?