Crazy_Man 36 Posted March 22, 2019 Hello, I want to sort an array of array with strings and numbers but only on the number. With the highest number at the start of the array. _array = [["Player 1",1], ["Player 2",3], ["Player 3", 2]]; // The result I want is : _array = [["Player 2",3], ["Player 3",2], ["Player 1", 1]]; Share this post Link to post Share on other sites
killzone_kid 1326 Posted March 22, 2019 Re-arrange your original array so that the number goes first. Is there a specific reason you want string be the 1st element? 1 Share this post Link to post Share on other sites
Crazy_Man 36 Posted March 22, 2019 Oh ok it works in this case, thanks killzone_kid! Share this post Link to post Share on other sites
Grumpy Old Man 3540 Posted March 23, 2019 6 hours ago, Crazy_Man said: Hello, I want to sort an array of array with strings and numbers but only on the number. With the highest number at the start of the array. _array = [["Player 1",1], ["Player 2",3], ["Player 3", 2]]; // The result I want is : _array = [["Player 2",3], ["Player 3",2], ["Player 1", 1]]; Simple sorting without having to manually do anything: _array = [["Player_1",1],["Player_2",5],["Player_3",2]]; _toSort = _array apply {[_x#1,_x#0]};//number is now first element _toSort sort false;//false for descending order _array = _toSort apply {[_x#1,_x#0]};//switch it again back to original order ["string",number] systemchat str _array; //prints: //[["Player_2",5],["Player_3",2],["Player_1",1]] Cheers Share this post Link to post Share on other sites