Need a sorting routine
#1
Does anyone have a sorting algorithm laying around I could use? Nothing fancy but something faster than a bubble sort.

I have the following I need to sort:

TYPE DATATYPE
    a AS INTEGER
    b AS INTEGER
    c AS INTEGER
END TYPE

REDIM SortedList(0) AS DATATYPE

The sort will only be done on the value of 'a' (SortedList().a) and the values can range from 1 to 32767.

The Index of SortedList() can also be from 1 to 32767.

The first thing you're probably thinking is why not have the index value equal the value in 'a'... There can be multiple duplicate values in 'a'.

A bubble sort will probably do fine for the array if less than 1000 indexes but I need a sort that will be faster than bubble for cases where the index surpasses 32000+

QuickSort? MergeSort? InsertionSort? Anyone? Smile
Software and cathedrals are much the same — first we build them, then we pray.
QB64 Tutorial
Reply


Messages In This Thread
Need a sorting routine - by TerryRitchie - 03-04-2023, 06:53 AM
RE: Need a sorting routine - by mnrvovrfc - 03-04-2023, 08:58 AM
RE: Need a sorting routine - by TerryRitchie - 03-04-2023, 05:34 PM
RE: Need a sorting routine - by mdijkens - 03-04-2023, 09:00 AM
RE: Need a sorting routine - by TerryRitchie - 03-04-2023, 06:16 PM
RE: Need a sorting routine - by bplus - 03-04-2023, 10:02 AM
RE: Need a sorting routine - by RhoSigma - 03-04-2023, 10:03 AM
RE: Need a sorting routine - by SMcNeill - 03-04-2023, 10:46 AM
RE: Need a sorting routine - by SMcNeill - 03-04-2023, 06:14 PM
RE: Need a sorting routine - by TerryRitchie - 03-04-2023, 06:30 PM
RE: Need a sorting routine - by SMcNeill - 03-04-2023, 06:27 PM
RE: Need a sorting routine - by SMcNeill - 03-04-2023, 06:47 PM
RE: Need a sorting routine - by TerryRitchie - 03-04-2023, 06:52 PM
RE: Need a sorting routine - by SMcNeill - 03-04-2023, 07:14 PM
RE: Need a sorting routine - by Dimster - 03-05-2023, 02:49 PM
RE: Need a sorting routine - by TempodiBasic - 03-11-2023, 02:26 AM
RE: Need a sorting routine - by TempodiBasic - 03-11-2023, 02:34 AM



Users browsing this thread: 5 Guest(s)