I have two arrays containing objects. One of them contains the keys in some order, and the other contains the data, and I need to sort the data array according to the given array of sorted keys. How can i do this?
var a = ['d','a','b','c'] ;
var b = [{a:1},{c:3},{d:4},{b:2}];
The result should be:
result = [{d:4},{a:1},{b:2},{c:3]
source
share