Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / sorting arrays into alphabetical order or numerical order...

Author
Message
Duffer
23
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 5th Jun 2003 02:12
anyone got a code snippet for the easiest most efficient way>?
madbilly
23
Years of Service
User Offline
Joined: 20th Mar 2003
Location: United Kingdom
Posted: 5th Jun 2003 02:19
No, sorry, but you could get a book, or search the net for various sorting algorithms. Quicksort is the fastest algorithm, but there are plenty (Bucket sort, Mergesort, Heapsort, Shell sort, Insertion sort). I've not implemented any in DB yet, but somebody may have done. You could use google and just search the darkbasic webite and it might come up with something.
Andy Igoe
23
Years of Service
User Offline
Joined: 6th Oct 2002
Location: United Kingdom
Posted: 5th Jun 2003 02:25
It's a high score chart

Based upon ASCII value so you will find numbers sort before upper case (capitals) which sort before lower case (little letters).



Pneumatic Dryll
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 5th Jun 2003 02:29
You could use a DLL I wrote that you'll find on my site that implements a quicksort for all arrays, except for UDT arrays.

Otherwise, I'd suggest just doing a simple bubble sort. Just go though the list repeatedly swapping single pairs if they are not in sequence until you can go through the list without any swaps.

It's not the most efficient, but it's the easiest, and you won't notice the speed unless you try and sort hundreds of items.
Duffer
23
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 7th Jun 2003 00:19
thanks to you all...

Codger
23
Years of Service
User Offline
Joined: 23rd Nov 2002
Location:
Posted: 7th Jun 2003 01:12
Here is a good site to show sorting routines. Unless you only have a handfull of data avoid bubble sort

http://www.aeriesoft.ru/Projects/SortAlg/#Basic

Login to post a reply

Server time is: 2026-07-11 22:25:22
Your offset time is: 2026-07-11 22:25:22