title: Map using tuples or objects
body: <p>I'm trying to use the new (ES6) <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map"><code>Map</code></a> objects in order to represent a map between properties and a value.</p>
  
  <p>I have objects in a form similar to:</p>
  
  <pre><code> {key1:value1_1,key2:value2_1},..... {key1:value1_N,key2:value2_N}
  </code></pre>
  
  <p>I want to group them based on <em>both</em> their  key1 <em>and</em> key2 value.</p>
  
  <p>For example, I want to be able to group the following by <code>x</code> and <code>y</code>:</p>
  
  <pre><code>[{x:3,y:5,z:3},{x:3,y:4,z:4},{x:3,y:4,z:7},{x:3,y:1,z:1},{x:3,y:5,z:4}]
  </code></pre>
  
  <p>And obtain a Map containing:</p>
  
  <pre><code>{x:3,y:5} ==&gt;  {x:3,y:5,z:3},{x:3,y:5,z:4}
  {x:3,y:4} ==&gt;  {x:3,y:4,z:4},{x:3,y:4,z:7}
  {x:3,y:1} ==&gt;  {x:3,y:1,z:1}
  </code></pre>
  
  <p>In Python, I'd use tuples as dictionary keys. ES6 map allow arbitrary objects as keys but use the standard equality algorithm (<code>===</code>) so objects are only equal by reference from what I can tell.</p>
  
  <p>How can I accomplish this sort of grouping using ES6 maps? Alternatively, a solution using normal JS objects if there is an elegant way I overlooked.</p>
  
  <p>I'd rather not use an external collections library - but if there is a better solution using one I'm interested in learning about it too.</p>