im having a problem getting this leaderboard skript to work and i think it might be with sorting. please check my code and the image provided and see if you could tell me what ive done wrong
``command /leaderboard <text>:
trigger:
set {_stat} to arg-1
set {_validStats::*} to "kills", "deaths", "blocksBroken", "blocksPlaced", "distanceTraveled", "playtime", "amberMined"
if {_validStats::*} does not contain {_stat}:
send "&cInvalid statistic. Valid options: %{_validStats::*}%"
stop
delete {_data::*}
loop all players:
set {_uuid} to uuid of loop-player
set {_val} to {%{_stat}%.%loop-player%}
if {_val} is not set:
set {_val} to 0
set {_data::%loop-player%} to {_val}
loop all offline players:
set {_uuid} to uuid of loop-offlineplayer
set {_val} to {%{_stat}%.%loop-offlineplayer%}
if {_val} is not set:
set {_val} to 0
set {_data::%loop-offlineplayer%} to {_val}
send {_val} to all players
set {_sorted::*} to {_data::*}
set {_sorted::*} to sorted {_data::*}
send "&6Top 10 %{_stat}%:"
set {_rank} to 0
loop {_sorted::*}:
add 1 to {_rank}
send "&e%{_rank}%. %loop-index%: &f%loop-value%"
if {_rank} is 10:
stop loop
set {_me} to player
set {_pyRank} to 0
set {_i} to 0
loop {_sorted::*}:
add 1 to {_i}
if loop-index is {_me}:
set {_pyRank} to {_i}
stop loop
if {_pyRank} > 0:
send "&bYour rank in %{_stat}%: %{_pyRank}%"
else:
send "&bYou have no rank in %{_stat}%."
``