title: Javascript: How convert array of objects to object with sorted unique arrays?
body: <p>Have data that has this kind of structure:</p>
  
  <pre><code>$input = [ { animal: 'cat', name: 'Rocky', value: 1 },
             { animal: 'cat', name: 'Spot',  value: 2 },
             { animal: 'dog', name: 'Spot',  value: 3 } ];
  </code></pre>
  
  <p>Need fastest possible method for converting to this format:</p>
  
  <pre><code>$output = { animal: [ 'cat', 'dog' ],
              name: [ 'Rocky', 'Spot' ],
              value: [ 1, 2, 3 ] };
  </code></pre>
  
  <p>The output should have keys equal to each of the keys in each object from the input. And the output values should be arrays with the sorted unique values.  I found a few ways to do it using nested loops, but slower than I would like.  With 30,000 elements to the input array with 8 keys for each of the objects, the best I have been able to do is 300ms in Chrome.  Would like to get down to 100ms.  Is there any faster method using a map or reduce?</p>