System Sorting Trigger

Ghan

Administrator - Servers are fun
Staff member
Reaction score
898
Well, this is only one trigger, but it IS kind of a system. I looked to see if something like this has been posted before, but I didn't find anything. If there's already a system like this that I missed, just delete this. This trigger is used to sort integers.
 

Attachments

  • Integer Sorting.w3x
    17.4 KB · Views: 295
Mind telling us whats this about. The title isnt very discriptive...
 
This trigger uses an integer so it knows how many numbers it has to sort, then it uses an integer array for the actual numbers. It takes that array of integer numbers and sorts them into decending order. Implementation instructions come with the trigger.
 
I haven't tried to max out the limit. I imagine it would work for as many variables as you can put in the array.
 
> isn't the max array size 8192?

Yep.

Though I seriously doubt you can sort an array with that many elements.


How many did you try this with? 5? 10? 50? What about 500?
 
Hmm... I see an error in as little as 100 numbers. Why does that happen? Is the trigger hitting its execution limit?

EDIT: Fixed. The trigger will now sort over 1000 integers. (Well, I didn't watch it display them all :p , but it went down from 1000 through the 900's with no errors.) However, it did take a some time to do the execution. (Not unexpected when the total execution number is in excess of oh, about 500000. :D I believe the limit it can sort is in the area of 6250, since that is the maximum number of loops that can occur before the trigger crashes.

>Though I seriously doubt you can sort an array with that many elements.

I got close! :p I tried sorting 8000 random integers, but the game crashed after locking up for about 15 seconds.
 
Swapping can be done with one single helper variable, and without array.
set t = array[this]
set array[this] = array[that]
set array[that] = t

Find a better algorithm.
Bubblesort doesn't really cut it, unless it's less than 50 values or so.
 
I optimized the code so that it will stop when there are no more changes to be made, but as for implementing a whole new algorithm, i'm finding it difficult to put any of them into JASS at the moment.

EDIT: Combsort effectively implemented.
 
Bump

Well, I think Combsort is the best i'm going to get. JASS just doesn't seem to be made for most sorting algorithms (more likely it's just beyond me). Combsort is the only one of the exchanging algorithms with a worst-case memory cost of (n log n), so it's not bad.
 
>Well, how far up does it go?

As high as the previous version, which is to say, as many integers as you can come up with. :p I don't know what the limit is, but it is in excess of 1000.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    News portal has been retired. Main page of site goes to Headline News forum now
  • The Helper The Helper:
    I am working on getting access to the old news portal under a different URL for those that would rather use that for news before we get a different news view.
  • Ghan Ghan:
    Easily done
    +1
  • The Helper The Helper:
    https://www.thehelper.net/pages/news/ is a link to the old news portal - i will integrate it into the interface somewhere when i figure it out
  • Ghan Ghan:
    Need to try something
  • Ghan Ghan:
    Hopefully this won't cause problems.
  • Ghan Ghan:
    Hmm
  • Ghan Ghan:
    I have converted the Headline News forum to an Article type forum. It will now show the top 20 threads with more detail of each thread.
  • Ghan Ghan:
    See how we like that.
  • The Helper The Helper:
    I do not see a way to go past the 1st page of posts on the forum though
  • The Helper The Helper:
    It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
  • Ghan Ghan:
    Yeah I'm not sure what the deal is with the pagination.
  • Ghan Ghan:
    It SHOULD be there so I think it might just be an artifact of having an older style.
  • Ghan Ghan:
    I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
  • The Helper The Helper:
    I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
  • Ghan Ghan:
    RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
  • The Helper The Helper:
  • The Helper The Helper:
    What do you think Tom?
  • tom_mai78101 tom_mai78101:
    I will have to get used to this.
  • tom_mai78101 tom_mai78101:
    The latest news feed looks good
  • The Helper The Helper:
    I would like to see it again like Ghan had it the first time with pagination though - without the pagination that view will not work but with pagination it just might...
  • The Helper The Helper:
    This drink recipe I have had more than a few times back in the day! Mind Eraser https://www.thehelper.net/threads/cocktail-mind-eraser.194720/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top