Number Sort Algorithm


Results 1 to 40 of 55

Threaded View

  1. #16
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Thank you, thank you,

    So now that I've proven to myself that it works, ...
    back to the topic ...

    I think that changes Melanie's Sort from Post #4, to ...
    Code:
    	CounterA var Byte
    	RawData var Byte [16]
    	.. ..
    
    		'
    		'	Sort Array
    		'	----------
    SortArray:
    	CounterA=0
    SortLoop:
    	If RawData(CounterA+1) < RawData(CounterA) then
    		RawData(CounterA)     = RawData(CounterA) ^ RawData(CounterA+1)
    		RawData(CounterA+1+0) = RawData(CounterA) ^ RawData(CounterA+1)
    		RawData(CounterA)     = RawData(CounterA) ^ RawData(CounterA+1)
    		If CounterA > 0 then CounterA=CounterA-2
    		endif
    	CounterA=CounterA+1
    	If CounterA < 15 then goto SortLoop
    	Return
    Now I've got to wonder if it makes any difference?

    edit: The added array operations would probably even slow it down.
    <br>
    Last edited by Darrel Taylor; - 26th July 2007 at 13:07. Reason: .
    DT

Similar Threads

  1. Dynamic USB Serial Number (PIC18F4550)
    By awmt102 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 16th July 2009, 17:03
  2. Working with the random number generator
    By kwelna in forum mel PIC BASIC
    Replies: 9
    Last Post: - 16th January 2007, 17:50
  3. Random number results
    By bartman in forum mel PIC BASIC
    Replies: 3
    Last Post: - 9th March 2005, 17:39
  4. more random number questions
    By bartman in forum mel PIC BASIC
    Replies: 1
    Last Post: - 14th November 2004, 17:55
  5. Split number into variables
    By psmeets in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 7th January 2004, 04:15

Members who have read this thread : 2

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts