Login
Create

Sorted Array Last updated July 06, 2020

A Sorted Array is a value you can use in your script to get a sorted version of the specified array. This can be used for numerous things since you can specify how you want it sorted. When you use this value on your array, it goes through your array and uses the Value Rank to determine where it should place each element in the new array, without modifying the original array.

When setting the Value Rank of your sorted array, you don't just wanna pass in a random number, since this rank should be related to the element currently being sorted in the array. You can use Current Array Element for this. It represents the "Current Element Being Sorted" in the array as it iterates over it. So for example if you're sorting an array of players, such as the All Players value, it will represent each player, one at a time, as it's going through the array and sorting it.

The Value Rank needs to be a number. Your script uses this number to determine where in the new array the element should be placed. If you use Current Array Element as the value rank for an array of players, that won't really make any sense. A player isn't a number. You could however set the value rank to be the Score Of -> Current Array Element. This means the new array will be sorted by player score, in ascending order, so the first element is the player with the lowest score, and the last element is the player with the highest score. You can use the First Of and Last Of values to easily access those in your script.

Getting an array of all players, sorted by their score.

Description

A copy of the specified array with the values sorted according to the value rank that is evaluated for each element.

Return

array: object

Arguments

Name: ARRAY
Description: The array whose copy will be sorted.
Type:
Array: Object
Default: GLOBAL VARIABLE

Name: VALUE RANK
Description: The value that is evaluated for each element of the copied array. The array is sorted by this rank in ascending order. Use the current array element value to reference the element of the array currently being considered.
Type: Object
Default: CURRENT ARRAY ELEMENT

Elo Hell Logo_H-M-Dark
Join the Elo Hell Workshops Discord