show low value first

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
siliconchip
Posts: 392
Joined: Wed Jan 05, 2011 11:24 am
Has thanked: 101 times
Been thanked: 24 times
Contact:

show low value first

Post by siliconchip »

hi if i have say a variable byte called number[2] and have 3 values within for example
number[0] = 71
number[1] = 4
number [2] = 52
how would I arrange the program to show the lowest value first ?

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: show low value first

Post by Benj »

Hello,

You would have to loop through the array each time and either populate another array with the correct order from low to high or re-parsing through the entire array to pull out each new value by recording the current value and comparing with the current position in the array.

siliconchip
Posts: 392
Joined: Wed Jan 05, 2011 11:24 am
Has thanked: 101 times
Been thanked: 24 times
Contact:

Re: show low value first

Post by siliconchip »

hi benj thanks for the reply but im still a little fazed by this :oops:

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: show low value first

Post by Benj »

Hello,

I can do you a simple example.

Which method is more acceptable for you, reordering the array into another array of the same size once (RAM based) or reparsing through the entire array on each iteration (ROM based)?

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: show low value first

Post by LeighM »

You could also try a Bubble Sort. Google and wiki for an algorithm :D

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: show low value first

Post by medelec35 »

LeighM wrote:You could also try a Bubble Sort
I did a bubble sort some time ago:
http://www.matrixmultimedia.com/mmforum ... 73&#p22074
You many need to look at the whole of the thread to see which flowchart would suit you the most (if any?).

Martin
Martin

siliconchip
Posts: 392
Joined: Wed Jan 05, 2011 11:24 am
Has thanked: 101 times
Been thanked: 24 times
Contact:

Re: show low value first

Post by siliconchip »

hi benj im not sure about ram or rom based , martin I looked at the bubble sort but im after a set of 3 random numbers being picked and being then placed in variables ie number[0],number[1]and number[2] these are displayed again in order ie if 40 71 5 were picked then they would be shown as 5, 40, 71,

siliconchip
Posts: 392
Joined: Wed Jan 05, 2011 11:24 am
Has thanked: 101 times
Been thanked: 24 times
Contact:

Re: show low value first

Post by siliconchip »

hi martin / benj I have added a flow chart that picks my 3 numbers then displays them but im looking at them being placed from low to high
Attachments
LOW TO HIGH.fcf
(18.36 KiB) Downloaded 307 times

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: show low value first

Post by medelec35 »

Hi Bob,
I implemented the bubble sort that I posted a link to.
Hopefully it's working the way you want it to.

Hint If you never want a repeated random number, e.g 4,6, & 4 then check out my Lottery generator:
http://www.matrixmultimedia.com/mmforum ... =26&t=8025

Martin
Attachments
LOW TO HIGH V2a.fcf
(22.29 KiB) Downloaded 297 times
Martin

siliconchip
Posts: 392
Joined: Wed Jan 05, 2011 11:24 am
Has thanked: 101 times
Been thanked: 24 times
Contact:

Re: show low value first

Post by siliconchip »

hi martin this is perfect exactly what i have been trying to achieve but I was way off the mark it works perfect, once again many thanks for helping me out and thanks to benj i now intend to interrogate the bubble sort flowchart and try to break it down to work out how it operates once again thanks :P

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: show low value first

Post by medelec35 »

Hi Bob,
Your welcome.
Just glad it's what you're after.

Thanks for letting us know. :)

Martin
Martin

siliconchip
Posts: 392
Joined: Wed Jan 05, 2011 11:24 am
Has thanked: 101 times
Been thanked: 24 times
Contact:

Re: show low value first

Post by siliconchip »

martin I have attempted to make a better random generator, and im happy with it but I tried to add the bubble sort part as per version 2 but I cannot get it to work as my new flowchart is different ive spent most of the day trying to add it in various places changing variables etc but no joy. HELP :?
Attachments
LOW TO HIGH V3.fcf
(24.71 KiB) Downloaded 274 times

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: show low value first

Post by medelec35 »

Hi Bob,
On V2a I added a bubble sort macro
That macro was missed out in version 3.

Martin
Attachments
LOW TO HIGH V3a.fcf
(28.87 KiB) Downloaded 242 times
Martin

siliconchip
Posts: 392
Joined: Wed Jan 05, 2011 11:24 am
Has thanked: 101 times
Been thanked: 24 times
Contact:

Re: show low value first

Post by siliconchip »

hi martin I had added the bubblesort macro when I was trying to get it to work I used V2 as a guide to see where you had added the macro in the main flow chart but being up late working on a new generator as well as today left me getting in knots so i removed the macro leaving a clean sheet ready for some help, but once again you have sorted me out again many many thanks, :D

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: show low value first

Post by medelec35 »

Ah I see, fair enough.
If you need help in finding out how the routine works, then by all means give me a shout.

Martin
Martin

siliconchip
Posts: 392
Joined: Wed Jan 05, 2011 11:24 am
Has thanked: 101 times
Been thanked: 24 times
Contact:

Re: show low value first

Post by siliconchip »

hi martin im going to go through the code to try and work it out but I shall take you up on your offer if i get stuck cheers

Post Reply