Sorting from Highest to Lowest

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

Blobbyguy

Member
Feb 2, 2017
25
0
0
Bloblandia
Hi, I would like to figure out a way to sort a list variable from highest to lowest ({list::*})

I can't use the RandomSK way as I am on 1.9.4

I also would rather not switch SK versions however I am open to any other addons that do the job

SK Version: 2.2
Author: Nfell
MC Version: 1.9.4
 
code_language.skript:
set {_topboard::*} to {your variable::*}
loop {_topboard::*}:
    add loop-index to {_indexes::*}
    if loop-integer is divisible by 20: #SkQuery
        wait 1 tick
loop size of {_topboard::*} times:
    set {_index} to 1
    loop {_topboard::*}:
        add 1 to {_index}
        set {_next} to {_topboard::%{_indexes::%{_index}%}%}
        loop-value-2 is less than {_next}
        {_index} is less or equal to size of {_topboard::*}
        set {_topboard::%{_indexes::%{_index}%}%} to loop-value-2
        set {_topboard::%loop-index%} to {_next}
    #Use this part if your list is too long, to prevent your server to lag
    #or another method if you want
    if loop-integer is divisible by 20: #SkQuery
        wait 1 tick


From @Snow-Pyon
 
Or you can use Bensku's edit

code_language.skript:
add 132353, 2432, 12425 and 242364 to {_sortThis::*}
set {_sorted::*} to sorted {_sortThis::*}
 
Status
Not open for further replies.