title: Does shuffling happens before reduce function is called in the reducer task?
body: <p>eg in a word count job,
  I have 2 mappers Mapper A and Mapper B.</p>
  
  <p>The output of mapper A is: <code>{hi,1},{hello,1},{hey,1}</code></p>
  
  <p>The output of mapper B is: <code>{hi,1},{bye,1},{hey,1}</code></p>
  
  <p>Suppose, there is no combiner and 1 reducer</p>
  
  <p>then, first, shuffling happens</p>
  
  <p>so, in shuffling the output of both the mappers merge and the resultant is:</p>
  
  <pre><code>{hi,[1,1]},{hello,1},{hey,[1,1]},{bye,1}
  </code></pre>
  
  <p>then sorting happens:</p>
  
  <pre><code>{bye,1},{hello,1},{hey,[1,1]},{hi,[1,1]}
  </code></pre>
  
  <p>then the reduce function in the reducer task is called which makes the o/p as:</p>
  
  <pre><code>bye,2
  hello,1
  hey,2
  hi,2
  </code></pre>
  
  <p>Is the above process correct? And does shuffling happens before reduce function is called? or the scheduler just accumulates data together from different mappers but do not group the data with the same key together and this process happens after sorting? Why is sorting useful here?</p>