title: What is the use of grouping comparator in hadoop map reduce
body: <p>I would like to know why grouping comparator is used in secondary sort of mapreduce.</p>
  
  <p>According to the definitive guide example of secondary sorting</p>
  
  <p>We want the sort order for keys to be by year (ascending) and then by
  temperature (descending):</p>
  
  <pre><code>1900 35°C
  1900 34°C
  1900 34°C
  ...
  1901 36°C
  1901 35°C
  </code></pre>
  
  <p>By setting a partitioner to partition by the year part of the key, we can guarantee that
  records for the same year go to the same reducer. This still isn’t enough to achieve our
  goal, however. A partitioner ensures only that one reducer receives all the records for
  a year; it doesn’t change the fact that the reducer groups by key within the partition.</p>
  
  <p>Since we would have already written our own partitioner which would take care of the map output keys going to particular reducer,so why should we group it.</p>
  
  <p>Thanks in advance</p>