Sorting an array of objects with multiple entries
<p>I would like to rearrange an array of objects in javascript, which looks like this:</p>

<pre><code>[{ year: "1950-12-20", product: ["product 1", "product 2, "product 3"] }, { year: "1951-12-20", product: ["product 3", "product 2"] }, { year: "1952-12-20", product: ["product 3", "product 4"] }]
</code></pre>

<p>so that I get two arrays, one with the products and one with the years when they appear.</p>

<pre><code>a = ["product 1", "product 2", "product 3", "product 4"]
b = ["1950-12-20", [ "1950-12-20, "1951-12-20"],["1950-12-20", "1951-12-20", "1952-12-20"],"1952-12-20"]
</code></pre>

<p>I have tried to loop through each object through nestled for-loops, but how do I treat the array of strings in the object array in a nice way? </p>
