System Sorting Trigger

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
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: 288

martix

There is no spoon
Reaction score
49
Mind telling us whats this about. The title isnt very discriptive...
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
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.
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
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.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,494
> 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?
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
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.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,494
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.
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
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.
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
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.
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
>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 Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top