title: Using a set of integers to generate unique key
body: <p>Now I have some sets of integers, say:</p>
  
  <pre><code>   set1 = {int1, int2, int3};
     set2 = {int2, int3, int1};
     set3 = {int1, int4, int2};
  </code></pre>
  
  <p>The order or the numbers is not taken into consideration, so set1 and set2 are the same, while set3 are not with the other two.</p>
  
  <p>Now I want to generate a unique key for these sets to distinguish them, in that way, set1 and set2 should generate the same key.</p>
  
  <p>I think this for a while, thoughts as sum up the integers came to my mind but can be easily proved wrong. Sort the set and do </p>
  
  <pre><code>key = n1 + n2*2^16 + n3*2^32
  </code></pre>
  
  <p>may be a possible way but I wonder if this can be solved more elegantly.
  The key can be either integer or string.</p>
  
  <p>So any one has some idea about solving this as fast as possible? Or any reading material is welcome.</p>
  
  <p>More info:
  The numbers are in fact colors so each integer is less than 0xffffff</p>