Possible Duplicate:
Simple function to sort an array of objects
While writing the script, there was a problem with sorting an array. I have an array of objects:
[{gold: false, range: 1601}, {gold: true, range: 13}, {gold: false, range: 375}, {gold: true, range: 601}
But it should look like this:
[{gold: true, range: 13}, {gold: true, range: 601}, {gold:false, range: 375}, {gold: false, range: 1601}]
I want to get an array in which the keys are sorted by increasing range. But if there gold key value is true, then they are the first.