#Sorting list of variables

1 messages · Page 1 of 1 (latest)

clear herald
#

You can use the loop-iteration expression instead of creating and incrementing {_num}

#

also,

fathom prismBOT
#

x8ight suggests that you read this embed

Sorted Indices

The sorted indices expression returns a new list of indices sorted by the value of the index. This can be very helpful for making all sorts of leaderboards. Lets say we have the balances of our players saved in the variable {balance::%player's uuid%}. To create our leaderboard we can use```vb
set {_sorted::} to sorted indices of {balance::} in descending order````{_sorted::*}will be a list of uuids with{_sorted::1}being the person with the most money. If we wanted to check how much money they had we could plug the uuid back into the original variable:{balance::%{_sorted::1}%}`

Leaderboard Example
command /baltop:
    trigger:
        set {_sorted::*} to sorted indices of {balance::*} in descending order
        send "<aqua>Baltop"
        loop first 10 elements of {_sorted::*}:
            send "<gold>%loop-iteration%. <white>%offlineplayer(loop-value)% <gray>- <green>$%{balance::%loop-value%}%"```
fallen pumice
#

thank you very much @clear herald

#

I’m same person just went afk

blazing dome
#

loop {%{_leaderboard}%::*}:
if {%{_leaderboard}%::%loop-value%} > 0:

is the this proper syntax for this part {%{_leaderboard}%::%loop-value%}