title: Java program to sort a list of date which is in format dd MMM yyyy
body: <p>Input is a list containing date in String format. I have solution as below. But i feel it can be made more efficient. Any help would be appreciated.</p>
  
  <p>//Map to store month data</p>
  
  <pre><code>HashMap&lt;String,String&gt; month = new HashMap&lt;String,String&gt;();
          month.put("Jan","01");
          month.put("Feb","02");
          month.put("Mar","03");
          month.put("Apr","04");
          month.put("May","05");
          month.put("Jun","06");
          month.put("Jul","07");
          month.put("Aug","08");
          month.put("Sep","09");
          month.put("Oct","10");
          month.put("Nov","11");
          month.put("Dec","12");
  </code></pre>
  
  <p>You can consider this as input</p>
  
  <pre><code>    String[] input = {"20 Oct 2052",
      "26 May 1960",
      "06 Jun 1933",
      "06 Jun 1933",
      "06 Jun 1933",
  };
  
  
      ArrayList&lt;Long&gt; temp1 = new ArrayList&lt;Long&gt;();
  </code></pre>
  
  <p>To compare result    </p>
  
  <pre><code>    HashMap&lt;Long,String&gt; temp2 = new HashMap&lt;Long,String&gt;();
  
      ArrayList&lt;String&gt; result = new ArrayList&lt;String&gt;();
      for(int i = 0 ; i&lt; input.length ; i++){
          String j = "";
          if(input[i].length() == 11){
  
              j+= input[i].substring(7,11);
              j+= month.get(input[i].substring(3,6));
              j+=input[i].substring(0,2);
  
              temp1.add(Long.parseLong(j));
              temp2.put(Long.parseLong(j), input[i]);   
          }
      }
  </code></pre>
  
  <p>Sorting the result</p>
  
  <pre><code>Collections.sort(temp1);
  </code></pre>
  
  <p>Printing the result</p>
  
  <pre><code>System.out.println(temp1.toString());
  </code></pre>