News:

PlayBASIC2DLL V0.99 Revision I Commercial Edition released! - Convert PlayBASIC programs to super fast Machine Code. 

Main Menu

Bubble Sort Typed (Character) Array

Started by kevin, January 31, 2008, 02:41:24 PM

Previous topic - Next topic

kevin

  Bubble Sort Typed  (Character) Array

  This example sorts all of the characters stored in the Characters() array in order, based upon their width values.  For simplicity the function uses bubble sorting algorithm, which is not quick, but hopefully easier for you to decipher how the type swapping is implemented.  Which is the trick here. Now rather than copy the elements manually (copy all the fields), this routine accesses the array directly (via pointer) and simply swaps the pair of type handles.   This way,  the size (in bytes of each element) won't impact upon the speed on the swap.    


Other Sorting Examples

   QuickSort Typed Array
   Radix Sort Array
   Better Bubble Sorting



Download

    Attached