JSFiddle - React, Tailwind, and code Playground

JavaScript

function orderArray(array_with_order, array_to_order) {
    var ordered_array = [],
        len = array_to_order.length,
        len_copy = len,
        index, current;
    
    for (; len--;) {
        current = array_to_order[len];
        index = array_with_order.indexOf(current.key);
        ordered_array[index] = current;
    }
    
    Array.prototype.splice.apply(array_to_order, [0, len_copy].concat(ordered_array));
}


var array_with_order = ['one', 'four', 'two'],

    array_to_order = [
        {key: 'one'},
        {key: 'four'},
        {key: 'two'}
    ];
        
orderArray(array_with_order, array_to_order);
    
console.log(array_to_order);