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

Hi Anonymous Monk,

Please note. I am not stating that this is the best one there ever was. Just stating that this is the best one I could come up with.

As for the script not working when the biggest number is a negative, here is what I tried

my @array = (-10,30,5,0b1011,7,9,8, -01111,-10,1,-0xFFF,-19923,3,9,-30 +,5,-100,0,-1,0xFF,-3,30,0b1011,3,2,-300,-0xFF,15);

And here is what I get

@array with 28 elements = -10 30 5 11 7 9 8 -585 -10 1 -4095 -1992 +3 3 9 -30 5 -100 0 -1 255 -3 30 11 3 2 -300 -255 15 @sorted with 28 elements = -19923 -4095 -585 -300 -255 -100 -30 -10 + -10 -3 -1 0 1 2 3 3 5 5 7 8 9 9 11 11 15 30 30 255

Even when there are no negative numbers, the script seems to work fine

my @array = (5,3,4,5,5,1,432,4,3,2)

Output:

@array with 10 elements = 5 3 4 5 5 1 432 4 3 2 @sorted with 10 elements = 1 2 3 3 4 4 5 5 5 432

Kindly let me know which numbers did you try in the list when you noticed the issue

As for CPAN having a lot of pre tested and production ready sort functions, I wholehearted agree with that, and I also know that Perl has it's own sort function, which serves the purpose pretty well. I was just doing this to pacify my own curiosity.