Array Number Sorter by Lost In Code12th Aug 2004 8:46
|
---|
Summary This is a small demo on how you can sort a filled array with numbers. Description This code will help you sort your arrays from least to greatest. There are notes to help out. Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com `Array Sorting code `08/12/04 05:34AM `by Dan Davis `Set up the Arrays dim array1(9)`raw data dim array2(9)`Sorted `Randomly fill the array (Realy don't worry about this part) for I = 0 to 9 array1(I)=RandomNumber() next I `Every thing is randomly filled SortArray() PrintSorted() Wait Key Function SortArray() `This is the Function that does all the sorting newarray = 0 compairNumber = 0 for CountTo = 0 to 300 for arraycount = 0 to 9 if array1(arraycount) = compairNumber array2(newarray) = countTo newarray = newarray + 1 endif next arraycount compairNumber = CompairNumber + 1 next CountTo endfunction Function PrintSorted() `This Function Prints the sorted array for I = 0 to 9 print array2(I) next I endfunction function RandomNumber() `This is just for random numbers to test with number = rnd(300) endfunction number |