in reply to Re: Sorting a File which contains numbers
in thread Sorting a File which contains numbers

Your solution is going to fail as soon as you encounter numbers that are more than single-digits because the default sort that you use is lexical, not numeric. Consider

perl -le '@arr = (2, 17, 8, 5, 26); print for sort @arr;'

produces

17 2 26 5 8

whereas

perl -le '@arr = (2, 17, 8, 5, 26); print for sort {$a <=> $b} @arr;'

does a numerical sort and produces

2 5 8 17 26

To sort descending numerically change the anonymous sort routine to {$b <=> $a} rather than using reverse.

Cheers,

JohnGG