Shop OBEX P1 Docs P2 Docs Learn Events
Number Order — Parallax Forums

Number Order

Mr.BillMr.Bill Posts: 7
edited 2012-05-29 10:09 in BASIC Stamp
Hi to everyone.

I'm entering a series of numbers in random value order from the keyboard into my BS2.

Is there a simple way to have the stamp organize them from lowest value to highest?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2012-02-05 15:06
    It's called a sort. How many numbers do you plan to have? I assume you're talking about 16-bit numbers, but the same things can be done with byte values. Do you want to store them in order as they're entered or do you want to rearrange them at some point. Do a Wikipedia search for Bubble Sort and Insertion Sort. An insertion sort would be the simplest and most efficient for a small set of values.
  • Mr.BillMr.Bill Posts: 7
    edited 2012-02-05 15:10
    Thanks Mike. I'll have 20 numbers, byte values. I'd like to store them in order as they're entered.
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2012-02-05 15:15
    Here are a couple of past threads I had bookmarked on this subject.

    Sorting

    Computing-a-running-median
  • Mr.BillMr.Bill Posts: 7
    edited 2012-02-05 15:21
    Thanks Tracy i'll have a look.
  • Mr.BillMr.Bill Posts: 7
    edited 2012-05-15 11:53
    Hi to all again,

    Thanks again for your previous help. I've found a good bubble sort progam for my BS2 but it uses SortArray which I think would use eeprom memory and may eventually stop working.
    I have a BS2sx stamp also...is it possible to "sort an array" in scratch pad memory instead?
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2012-05-15 20:01
    Yes, you can sort to the scratchpad RAM. If your existing program does READ and WRITE you would be able to replace that with GET and PUT. The addresses for scratchpad RAM run from 0 to 126 for the BS2p series, half that for the BS2e and BS2sx.

    The link in post #4 points to a bubble sort that uses scratchpad.
  • Mr.BillMr.Bill Posts: 7
    edited 2012-05-16 08:33
    Thanks Tracy, I'll have another look at it.
  • Mr.BillMr.Bill Posts: 7
    edited 2012-05-18 21:59
    I assumed that the sorting program I have was using eeprom, but after another look I don't think it is.
    Programming has never been my biggest strength lol.
  • Mr.BillMr.Bill Posts: 7
    edited 2012-05-29 10:09
    Well i'm back to square one again. I have a great bubble sort program (For Sort from the 123 robotics for the evil genius book online) as mentioned, it uses an array but I need to use the scratch pad memory of my BS2sx instead for more numbers. I've come close to making it work with PUT & GET but not fully...any more suggestions?
Sign In or Register to comment.