Solved Reverse sort?

  • 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.
Jan 27, 2017
38
5
8
33
I won't use the official format, because my question is too simple for that...

How can I reverse a variable list? When I use
Code:
set {_sorted::*} to sorted {_list::*}

it sorts the list in ascending order, but I need to have it in descending order... I don't mind to use any addon, my server version is 1.8.8 with some kind of development 2.2 skript and some addons.

Can someone help me to do that? I already searched in documentation and these forums, but wasn't able to find anything useful.

Thanks in advance.

Edit: I set my values in {_list::*} to negative values, so it sorted right way, but of course I had to remove later those "-" symbols from sorted values, but that isn't a big issue. I will keep this thread open for a day, maybe someone will know a better solution to this.
 
Last edited:
You can do this with a loop:
code_language.skript:
set {_sorted::*} to sorted {_list::*}
loop {_list::*}:
    set {_reversed::%loop-index%} to last element of {_sorted::*}
    remove {_sorted::%loop-index%} from {_sorted::*}
    #The following is only if the list is too big:
    #set {_current} to loop-index parsed as int / 50
    #if "%{_current}%" conains ".":
        #wait 1 tick
 
Status
Not open for further replies.