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

As long as you only want to sort a reasonable number of small positive integers, try sleep sort. It features a very nice behaviour regarding CPU load, but unfortunately, it is a little bit slow. Nevertheless, it does sort small positive integers quite well.

Some implementations also allow sorting positive floating point numbers.

By adding a sufficiently large number to the numbers to be sorted, the algorithm can easily be extended to sort both positive and negative numbers.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
  • Comment on Re: My best attempt at sorting. Kindly suggest improvements/modifications.