in reply to My best attempt at sorting. Kindly suggest improvements/modifications.

G'day pritesh,

Perl doesn't care how you present the numbers (decimal/octal/etc.). To sort numbers use the '<=>' operator (sometimes called the spaceship operator). The documentation for sort has a huge number of examples.

All you really needed here was:

my @unsorted = ( ... ); my @sorted = sort { $a <=> $b } @unsorted;

Here's a quick command line test to show that.

$ perl -E 'say "@{[ sort { $a <=> $b } 30,5,7,9,8, -01111,-10,1,3,9,-3 +0,5,-100,0,-1,0xFF,-3,30,3,2,-300,-0xFF,15 ]}"' -585 -300 -255 -100 -30 -10 -3 -1 0 1 2 3 3 5 5 7 8 9 9 15 30 30 255

— Ken