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

siliconchip
Posts: 240
Joined: Wed Jan 05, 2011 11:24 am
Has thanked: 71 times
Been thanked: 22 times
Contact:

show low value first

Postby siliconchip » Mon Jan 06, 2014 9:20 am

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: 14325
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4412 times
Been thanked: 4130 times
Contact:

Re: show low value first

Postby Benj » Mon Jan 06, 2014 10:48 am

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: 240
Joined: Wed Jan 05, 2011 11:24 am
Has thanked: 71 times
Been thanked: 22 times
Contact:

Re: show low value first

Postby siliconchip » Mon Jan 06, 2014 4:33 pm

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

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

Re: show low value first

Postby Benj » Mon Jan 06, 2014 4:45 pm

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: 1890
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 446 times
Been thanked: 640 times
Contact:

Re: show low value first

Postby LeighM » Mon Jan 06, 2014 5:08 pm

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

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

Re: show low value first

Postby medelec35 » Mon Jan 06, 2014 5:32 pm

LeighM wrote:You could also try a Bubble Sort

I did a bubble sort some time ago:
viewtopic.php?f=5&t=8012&p=22173&#p22074
You many need to look at the whole of the thread to see which flowchart would suit you the most (if any?).

Martin
These users thanked the author medelec35 for the post:
LeighM (Mon Jan 06, 2014 5:36 pm)
Rating: 5.26%
 
Martin

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

siliconchip
Posts: 240
Joined: Wed Jan 05, 2011 11:24 am
Has thanked: 71 times
Been thanked: 22 times
Contact:

Re: show low value first

Postby siliconchip » Mon Jan 06, 2014 5:59 pm

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: 240
Joined: Wed Jan 05, 2011 11:24 am
Has thanked: 71 times
Been thanked: 22 times
Contact:

Re: show low value first

Postby siliconchip » Mon Jan 06, 2014 8:08 pm

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 115 times

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

Re: show low value first

Postby medelec35 » Mon Jan 06, 2014 9:06 pm

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:
viewtopic.php?f=26&t=8025

Martin
Attachments
LOW TO HIGH V2a.fcf
(22.29 KiB) Downloaded 114 times
These users thanked the author medelec35 for the post (total 2):
siliconchip (Mon Jan 06, 2014 9:23 pm) • Benj (Tue Jan 07, 2014 12:01 pm)
Rating: 10.53%
 
Martin

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

siliconchip
Posts: 240
Joined: Wed Jan 05, 2011 11:24 am
Has thanked: 71 times
Been thanked: 22 times
Contact:

Re: show low value first

Postby siliconchip » Mon Jan 06, 2014 9:23 pm

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
These users thanked the author siliconchip for the post:
Benj (Tue Jan 07, 2014 12:01 pm)
Rating: 5.26%
 

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

Re: show low value first

Postby medelec35 » Tue Jan 07, 2014 10:04 am

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

Thanks for letting us know. :)

Martin
Martin

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

siliconchip
Posts: 240
Joined: Wed Jan 05, 2011 11:24 am
Has thanked: 71 times
Been thanked: 22 times
Contact:

Re: show low value first

Postby siliconchip » Tue Jan 07, 2014 1:54 pm

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 100 times

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

Re: show low value first

Postby medelec35 » Tue Jan 07, 2014 2:22 pm

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 103 times
Martin

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

siliconchip
Posts: 240
Joined: Wed Jan 05, 2011 11:24 am
Has thanked: 71 times
Been thanked: 22 times
Contact:

Re: show low value first

Postby siliconchip » Tue Jan 07, 2014 2:36 pm

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

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

Re: show low value first

Postby medelec35 » Tue Jan 07, 2014 7:16 pm

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

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

siliconchip
Posts: 240
Joined: Wed Jan 05, 2011 11:24 am
Has thanked: 71 times
Been thanked: 22 times
Contact:

Re: show low value first

Postby siliconchip » Tue Jan 07, 2014 8:00 pm

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