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

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?

Postby hyperion007 » Sun Jun 21, 2015 5:03 am

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.

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8476
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2433 times
Been thanked: 3487 times
Contact:

Re: how to order 10 numbers by size?

Postby medelec35 » Sun Jun 21, 2015 9:19 am

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 307 times
These users thanked the author medelec35 for the post:
Benj (Mon Sep 14, 2015 11:26 am)
Rating: 5.26%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8476
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2433 times
Been thanked: 3487 times
Contact:

Re: how to order 10 numbers by size?

Postby medelec35 » Sun Sep 13, 2015 9:52 pm

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

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

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?

Postby hyperion007 » Sat Sep 19, 2015 5:14 pm

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.