in reply to a way to do 'sort|uniq'
However, your Perl version isn't equivalent - it's removing anything that's not a number (s/[\D\n]//g contains many hooks to improvement - I'd write it as tr/0-9//cd or if you insist on a substitution: s/[\D]+//g).
If I were to do it in Perl, I'd remove the duplicates first (using a hash), then sort. If there are a lot of duplicates, this ought to win (although in modern Perls, sorting with many duplicates is fast).
|
|---|