how to order 10 numbers by size?

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
hyperion007
Posts: 528
Joined: Sat Dec 01, 2012 1:23 pm
Location: Sweden
Has thanked: 49 times
Been thanked: 101 times
Contact:

how to order 10 numbers by size?

Post by hyperion007 »

Let's say I want to read 10 sample values from a sensor and sort them by size and store them in that order from low to high in variable01, variable02, variable03... variable10.
How would you suggest I do this? I want to make sure I do it efficiently and don't do a lot of unnecessary calculations.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: how to order 10 numbers by size?

Post by medelec35 »

Hi Daniel,
Attached is an old bubble sort flowchart I created a while ago.
Although sorting 12 numbers, can easily be adapted for 10.
The variables are contained within an array.
If you require any further help then just post your flowchart.

Martin
Attachments
Bubble sort.fcf
(11.5 KiB) Downloaded 480 times
Martin

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: how to order 10 numbers by size?

Post by medelec35 »

Hi Daniel,
Did the bubble sort work ok for your application?
Martin

hyperion007
Posts: 528
Joined: Sat Dec 01, 2012 1:23 pm
Location: Sweden
Has thanked: 49 times
Been thanked: 101 times
Contact:

Re: how to order 10 numbers by size?

Post by hyperion007 »

Thanks, I have not had time to check back on this. I wanted a simple way of identifying outliers in an array of say 10 byte variables to get a more accurate way of determining an average value.

Post Reply