In javascript, I have an array:
letterArray ['a', 'e', 'i', 'o', 'u']
corresponding to that array, I have another array:
valueArray [12, 22, 7, 7, 3]
I want to sort the valueArray into
[22, 12, 7, 7, 3]
but the letterArray also needs to be sorted the same way:
['e', 'a', 'i', 'o', 'u']
How would I be able to do this?
You can do this using zipping method. I would use
_.zip.I’m afraid your example is complicated by having duplicate numbers which means you can not garantuee order on sorting. This is browser specific whether “i” or “o” comes first.