title: Java Hadoop sorting Words and its frequency
body: <p>My problem is sorting words base on the frquency in a file.</p>
  <p>My input is in this format:</p>
  <pre><code>Word:          Frequency:
  coffee         6
  good           9
  I              50
  morning        21
  happy          9
  </code></pre>
  <p>The expected output should be in this format:</p>
  <pre><code>Frequency:     Word:          
  50             I
  21             morning
  9              good
  9              happy
  6              coffee
  </code></pre>
  <p>My initial plan was to set the frequency as the key and the word as the value, but i am not sure if the duplicate key (9) will cause a conflict between the value (good &amp; happy).</p>
  <pre><code>public static class Map extends Mapper&lt;Text, Text, Text, Text&gt; {
      private Text frequency = new Text();
      private Text word = new Text();
      public void map(Text value, Text key, Context context) throws IOException, InterruptedException {
          word.set(value);
          frequency.set(key);
          context.write(key, value);
  </code></pre>
  <p>If the duplicate key does not cause a problem, is it correct to run the input through the above code? I understand that Hadoop will automatically sort the key, but not sure if it will be in descending or ascending order. my aim is to achieve a descending order.</p>