 <p>My solution has two steps:</p> <ol> <li>Collect the relevant elements from the original array, and sort them according to the subset order.</li> <li>Replace them in the original array with the new order.</li> </ol> <p>Here is the code:</p> <pre><code>mapped_elements = subset.map { |i| original.find { |j| j.keys == i.keys } } result = original.map do |i| if subset.find { |j| j.keys == i.keys } mapped_elements.shift else i end end </code></pre> <p>For <code>subset = [{c: "Gill", points: 2}, {b: "Will", points: 1}]</code> the result will be:</p> <pre><code>[{a: "Bill", points: 4}, {c: "Gill", points: 2}, {b: "Will", points: 3}, {d: "{Pill}", points: 1}] </code></pre> <p>For <code>subset = [{c: "Gill", points: 3}, {b: "Will", points: 2}, {a: "Bill", points: 1}]</code> the result will be:</p> <pre><code>[{c: "Gill", points: 3}, {b: "Will", points: 2}, {a: "Bill", points: 4}, {d: "Pill", points: 1}] </code></pre>