I have mutlriple objects called stations
. Each station has a property called money
.
stations[0].money = 2000
stations[1].money = 500
stations[2].money = 1200
stations[3].money = 2200
I want to create an array of stations indexes (0,1,2 and 3 in this example) but sorted by ammount of money each station has ascending by money. So I want to have:
var moneyArray = [1, 2, 0, 3]
what is the most elegant way to do it?