M. Adam Davis email (remove spam text)
It is possible that no one wants to spend the time making a routine that
might not work for you, or trying to extricate their routine from their
What kind of numbers are you sorting? Do you just have six registers
and you want to move the values around so they go from lowest to
highest? Are they signed (negative and positive) or unsigned(positive
And most importantly, what have you tried so far?
If you haven't tried anything (and are hoping for a quick simple piece
of code) then you'll get few responses.
There are several algorithms for sorting. One particularily simple
0. Clear a flag that indicates that the algorithm is still sorting
1. Compare locations (1) and (2).
2. If (1) is greater than (2) then swap the two values and set the flag
3. Compare locations (2) and (3).
4. If (2) is greater than (3) then swap the two values and set the flag
perform the same for 3 and 4, 4 and 5, 5 and 6.
7. If the flag is set, goto 0.
This algorithm is fairly simple and striaghtforward. If you are unsure
of its operation then perform the work on paper and it should become clear.
There are numerous code examples for comparing two registers and
swapping the values in two registers on http://piclist.com , so you
ought to be able to get this going fairly quickly. It is not the most
efficient sorter, bu I'll leave that research up to you.
NETCOURRIER.COM wrote: JISAK
http://www.piclist.com hint: The PICList is archived three different
ways. See http://www.piclist.com/#archives for details.
See also: www.piclist.com/techref/microchip/devices.htm?key=pic
You must be a member of the
piclist mailing list
(not only a www.piclist.com member) to post to the