Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
btpoole
Channel Surfer

Order Numbers

Is there anyway to order a group of numbers from smallest to highest value? I have parsed an xml based one particular filter. I would like to order the parse to numerical order. I am only dealing with 3 sets of numbers so nothing very large.
Example of return

123
789
456

I am passing these numbers into another function but the really need to be in numerical order.
0 Kudos
5 REPLIES 5
RokuMarkn
Visitor

Re: Order Numbers

There isn't a built in sort function but there is an insertion sort example in the videoplayer sample code.

--Mark
0 Kudos
BradC
Channel Surfer

Re: Order Numbers

with only 3 values, a simple bubble sort should be fine.


just add a value, then compare the second, then the third. real quick and easy.




https://www.youtube.com/watch?v=lyZQPjUT5B4&t=54s




for anyone who hasn't seen it, here's a fun audio/visual comparison of different sorting algorithms.

https://www.youtube.com/watch?v=kPRA0W1kECg
♦MiniGolf♦HangMan♦Brain Puck♦Retro Tennis♦BORK♦FLIP♦Pathogen♦Pathogen 2♦Shut the Box♦Birdie♦Logic♦Dots♦Pool♦küglo♦Bubble Wrap♦Trivia Channel♦Mancala♦Air Hockey♦Weather♦CAMERA♦Your Photos Screensaver♦Desert Beauty Screensaver♦Wild Lakes Screensaver♦
0 Kudos
Komag
Roku Guru

Re: Order Numbers

Oh my gosh, I was just mesmerized by that video :shock:
0 Kudos
NewManLiving
Visitor

Re: Order Numbers

There is a bs sort utility here:
https://github.com/dphang/roku-lib/blob ... tUtils.brs
My Channels: 2D API Framework Presentation: https://owner.roku.com/add/2M9LCVC
Updated: 11-11-2015 - Completed Keyboard interface
The Joel Channel ( Final Beta )
0 Kudos
BradC
Channel Surfer

Re: Order Numbers

"Komag" wrote:
Oh my gosh, I was just mesmerized by that video :shock:



I know, right? crazy interesting. Too bad they didn't use the same number of records for each method, but then I suppose the fact that they didn't is almost as useful for comparison sake.


Like I said, doesn't really matter what method you use for just 3 records, but the different sort methods are interesting as heck.
♦MiniGolf♦HangMan♦Brain Puck♦Retro Tennis♦BORK♦FLIP♦Pathogen♦Pathogen 2♦Shut the Box♦Birdie♦Logic♦Dots♦Pool♦küglo♦Bubble Wrap♦Trivia Channel♦Mancala♦Air Hockey♦Weather♦CAMERA♦Your Photos Screensaver♦Desert Beauty Screensaver♦Wild Lakes Screensaver♦
0 Kudos