show low value first
Moderator: Benj
-
- Posts: 392
- Joined: Wed Jan 05, 2011 11:24 am
- Has thanked: 101 times
- Been thanked: 24 times
- Contact:
show low value first
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 ?
number[0] = 71
number[1] = 4
number [2] = 52
how would I arrange the program to show the lowest value first ?
- 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
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 392
- Joined: Wed Jan 05, 2011 11:24 am
- Has thanked: 101 times
- Been thanked: 24 times
- Contact:
- 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
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)?
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)?
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- 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
I did a bubble sort some time ago:LeighM wrote:You could also try a Bubble Sort
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
-
- Posts: 392
- Joined: Wed Jan 05, 2011 11:24 am
- Has thanked: 101 times
- Been thanked: 24 times
- Contact:
Re: show low value first
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,
-
- Posts: 392
- Joined: Wed Jan 05, 2011 11:24 am
- Has thanked: 101 times
- Been thanked: 24 times
- Contact:
Re: show low value first
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
-
- 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
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
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
-
- Posts: 392
- Joined: Wed Jan 05, 2011 11:24 am
- Has thanked: 101 times
- Been thanked: 24 times
- Contact:
Re: show low value first
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
-
- 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
Hi Bob,
Your welcome.
Just glad it's what you're after.
Thanks for letting us know.
Martin
Your welcome.
Just glad it's what you're after.
Thanks for letting us know.
Martin
Martin
-
- Posts: 392
- Joined: Wed Jan 05, 2011 11:24 am
- Has thanked: 101 times
- Been thanked: 24 times
- Contact:
Re: show low value first
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
-
- 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
Hi Bob,
On V2a I added a bubble sort macro
That macro was missed out in version 3.
Martin
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
-
- Posts: 392
- Joined: Wed Jan 05, 2011 11:24 am
- Has thanked: 101 times
- Been thanked: 24 times
- Contact:
Re: show low value first
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,
-
- 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
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
If you need help in finding out how the routine works, then by all means give me a shout.
Martin
Martin
-
- Posts: 392
- Joined: Wed Jan 05, 2011 11:24 am
- Has thanked: 101 times
- Been thanked: 24 times
- Contact:
Re: show low value first
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