I have two js arrays, one contains strings, the other color codes, something like:
strings = ['one', 'twooo', 'tres', 'four']; colors = ['000000', 'ffffff', 'cccccc', '333333'];
I need to sort the first array by the length of the values, longer first. I know I can do something like:
strings.sort(function(a, b){ return b.length - a.length; });
But in this way I lose the color corresponding to each line. How can I sort both arrays while maintaining key pairing?
source share