March 28, 2024, 03:43:14 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Sorting algorithms

Started by Egil, November 06, 2017, 05:14:50 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Egil

The only time I needed a sorting routine was (in 1998) when I made a program for a friend to help him organize his goat breeding work a little better, and ended up with a heapsort routine which worked very fast. (Just modified an EB example to suit my needs)

Now I have been closely following Andy's work where he pushes his boundaries to new heights. The discussion on sorting was of special interrest to me. But it also made me wonder.
Does anyone know if particular sorting algorithms work better for certain tasks than other?



Egil
Support Amateur Radio  -  Have a ham  for dinner!

Andy

November 06, 2017, 05:32:12 AM #1 Last Edit: November 06, 2017, 05:34:42 AM by Andy
Egil,

I think it's all down to how much data you are likely to sort, how big the difference is between the minimum possible value and the maximum possible value, and of course how quickly you want the result.

For me the Bubble4Optimised sort works, that is at worst there may be say 200 entries that need sorting alphabetically, each entry cannot be more than 255 characters.

I tried the quick sort code - although it is faster, as a human I didn't see any difference.

Now, when I tried the bubble4optimised sort on my slower PC with 100,000 records it took hours, but the quick sort did it in less than 1 second.

Andy.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.