title: Java Mapreduce sort composite value
body: <p>I have a mapper that emits a Text (fruit name) key and a custom composite value city:count. I want to sort the composite values by the count prior to it arriving to the reducer such that the reducer can quickly determine which city has the highest count.</p>
  
  <p>The composite value class is an extension of WritableComparable and has methods for retrieving the count and city.</p>
  
  <p>What my reducer currently receives:</p>
  
  <pre><code>reducer 1 - oranges:&lt;london:2, chicago:15, charleston:6&gt;
  reducer 2 - apples:&lt;charleston:31, london:3, chicago:29&gt;
  ...
  </code></pre>
  
  <p>What I want my reducer to receive:</p>
  
  <pre><code>reducer 1 - oranges:&lt;chicago:15, charleston:6, london:2&gt;
  reducer 2 - apples:&lt;charleston:31, chicago:29, london:3&gt;
  </code></pre>
  
  <p>Logically, how do I make this happen? I've read several articles on Secondary Sorting/Ordering, but they tend to focus on composite keys as opposed to composite values. My keys don't need furthering partitioning nor do they need further sorting.</p>
  
  <p>Again, sorting by a composite VALUE not a composite key!</p>