Suppose I have a Javascript array, like so:
var test = [\'b\', \'c\', \'d\', \'a\'];
I want to sort the array. Obviously, I can just do th
You can accomplish this with a single line using es6 (generating a 0->N-1 index array and sorting it based on the input values).
0->N-1
var test = ['b', 'c', 'd', 'a'] var result = Array.from(Array(test.length).keys()) .sort((a, b) => test[a] < test[b] ? -1 : (test[b] < test[a]) | 0)