I have an array in javascript called 'environment' .
I wish to sort this array based on the length of the ids of the elements . I am doing this as follows :
for (i = 0; i < environment.length; i++) {
console.log(environment[i]['id']);
// prints dev,production,staging ... I want it to be dev,staging,production
}
How can I achieve this ? TIA :)