Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Sorting One Array Based on Values in another Array

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Sorting One Array Based on Values in another Array

    Does anyone understand the concept behind this (taken out of the Help file):
    Code:
    dim base_array[4] as C
    dim parallel_array[4] as C
    base_array[1] = "dog"
    base_array[2] = "rat"
    base_array[3] = "cat"
    base_array[4] = "bat"
    parallel_array[1] = "z"
    parallel_array[2] = "a"
    parallel_array[3] = "b"
    parallel_array[4] = "d"
    base_array.sort("", "parallel_array[value]")
    ? base_array
    = [1] = "rat"
    [2] = "cat"
    [3] = "bat"
    [4] = "dog"
    Not a whole lot of explanation in the Help file. It's like one of those IQ tests puzzlers. It took a cup of Joe to figured it out!
    Can you guess how it works?

    #2
    Re: Sorting One Array Based on Values in another Array

    parallel_array defines the "order" that each element in base_array has.

    base_array[1] = parallel_array[1] ==> "dog" = "z"
    base_array[2] = parallel_array[2] ==> "rat" = "a"
    base_array[3] = parallel_array[3] ==> "cat" = "b"
    base_array[4] = parallel_array[4] ==> "bat" = "d"

    The sort operation sorts parallel_array (default sort method is ascending): z,a,b,d ==> a,b,d,z

    Then it reorders base_array based on that result: dog,rat,cat,bat ==> rat,cat,bat,dog

    Maybe if I was trying to recreate an associative array like situation, this could be useful. Does Alpha's Xbasic have anything like associative arrays? I haven't done much digging there...
    ---
    Sarah
    Alpha Anywhere latest pre-release

    Comment


      #3
      Re: Sorting One Array Based on Values in another Array

      Nice try Sarah..but no. Try again.

      No associative arrays in alpha.

      Comment


        #4
        Re: Sorting One Array Based on Values in another Array

        I like Sarah's explanation but I think she stopped short of a complete answer. After sorting the parallel_array, the elements in base_array[] are repopulated. i.e. the value in base_array[4] started off as "bat", but is now "dog". In a way its sort of like the difference between looking at an indexed view of a group of records as compared to physically sorting the records by moving the records themselves.

        Comment


          #5
          Re: Sorting One Array Based on Values in another Array

          Originally posted by Tom Cone Jr View Post
          I like Sarah's explanation but I think she stopped short of a complete answer. After sorting the parallel_array, the elements in base_array[] are repopulated. i.e. the value in base_array[4] started off as "bat", but is now "dog". In a way its sort of like the difference between looking at an indexed view of a group of records as compared to physically sorting the records by moving the records themselves.
          Does "Then it reorders base_array based on that result" not indicate the same action? My bad for not being completely clear on that.
          Alpha Anywhere latest pre-release

          Comment


            #6
            Re: Sorting One Array Based on Values in another Array

            Hi, Sarah.

            I suppose that means we're in agreement !

            Now we'll both have to wait for enlightenment. <grin>

            Comment


              #7
              Re: Sorting One Array Based on Values in another Array

              Originally posted by Tom Cone Jr View Post
              Hi, Sarah.

              I suppose that means we're in agreement !

              Now we'll both have to wait for enlightenment. <grin>
              Apparently so. There are lots of reasons for wanting to sort an array based on a weighted index. Power in being explicit and what not.
              Alpha Anywhere latest pre-release

              Comment


                #8
                Re: Sorting One Array Based on Values in another Array

                Gabe
                It appears to work like string dictionary. Except here the relationship is by element number.
                Sort the second array and the order that 1,2,3,4 ends up so does the first array.
                For the life of me I can't think of a use for that but, who knows?

                Comment


                  #9
                  Re: Sorting One Array Based on Values in another Array

                  Not sure what do you mean by string dictionary? nor what is the collaterally to sorting?

                  Comment


                    #10
                    Re: Sorting One Array Based on Values in another Array

                    Gabe

                    Description
                    Xbasic supports the Collection data type. Collections are fine for relatively small sets of values. However, the StringDictionary object offers similar features, but is much faster than collections when used for very large lists. The StringDictionary object only supports character data.
                    I learned to use collections from Stan Mathews here http://msgboard.alphasoftware.com/al...ht=collections
                    I now use string dictionary instead of TABLE.EXTERNAL_RECORD_CONTENT_GET() if it will be required more than once.

                    Comment


                      #11
                      Re: Sorting One Array Based on Values in another Array

                      Understood, but that has nothing to do with sorting arrays especially this type of sorting.
                      The string dictionary establishes association between pairs.

                      Comment


                        #12
                        Re: Sorting One Array Based on Values in another Array

                        Originally posted by Ray in Capetown View Post
                        ... here the relationship is by element number.
                        Sort the second array, and the order that 1,2,3,4 ends up so does the first array.
                        For the life of me I can't think of a use for that but, who knows?
                        That sounds suspiciously like sorting in pairs.

                        Comment


                          #13
                          Re: Sorting One Array Based on Values in another Array

                          Yes, but there is no association between these "pairs" at all. IOW, there is no association between dog and z or rat and a, while in string dictionary the association is fixed. That's a totally different animal.

                          Comment


                            #14
                            Re: Sorting One Array Based on Values in another Array

                            Not that animal this animal - Dog Rat -related to Z A or B - is just a nonsensical illustration.
                            Ive thought of something tangible - the best I can do..

                            Lets say you have read all items code into one array, all item prices in another. I wouldn't know why but lets just say you did.
                            Then hypothetically you want to list all the items codes in order of price. you could use this command, sorting on the price array.
                            Whether you want to do that or not isn't the question, you asked initially 'what does it do'.
                            If you can think of a use for it I would be interested to learn - it may be a solution looking for a problem.
                            Hah. Unless you are just pulling my chain.
                            Ray

                            Comment


                              #15
                              Re: Sorting One Array Based on Values in another Array

                              I don't remember asking that question!
                              I know what it does and I figured out how alpha does the sorting. I was wondering, if anyone reading what it says in the help file could actually understand from what's said how alpha does the sorting. It's more like a riddle.
                              So far, only Sarah took a stab at it and, unfortunately, it is not the correct answer.

                              Comment

                              Working...
                              X