Arrange numbers in ascending order
Zap-o
Posts: 452
I am having some difficulties even getting started on this issue.
I want to take any 9 numbers and arrange the numbers in ascending order. The problem is that the 9 numbers could be anything (not floating point numbers) and I am not sure how to even start a programming loop to accomplish this.
For example say I have a set of numbers:
1,5,5,3,2,4,1,9,5
After some logic I would like to to have:
1,1,2,3,4,5,5,5,9
I just need a push in the right direction. I looked up medians in the forums but this did not help much since I am running the propeller.
I want to take any 9 numbers and arrange the numbers in ascending order. The problem is that the 9 numbers could be anything (not floating point numbers) and I am not sure how to even start a programming loop to accomplish this.
For example say I have a set of numbers:
1,5,5,3,2,4,1,9,5
After some logic I would like to to have:
1,1,2,3,4,5,5,5,9
I just need a push in the right direction. I looked up medians in the forums but this did not help much since I am running the propeller.
Comments
"bubble sort" is one way...
Thanks a million. Wiki shows this very clearly and now I can see the light at the end of the tunnel. I will begin programming this.
Again thanks
* Edited
Leon thanks as well, ill look further into that too.
There is an important sorting object, and a related thread considering the advantages and disadvantages of all of them..
edit: http://obex.parallax.com/objects/715/
This one looks promising..