title: Ruby two dimensional array sort based on first element
body: <p>I have a two dimensional array which has following structure</p>
  
  <pre><code>a = [["5/2013", 20.0, 6.0, 6.0], 
  ["7/2013", 73.0, 66.0, 66.0], 
  ["50/2013", 11530.0, 12625.27, 12087.75], 
  ["2/2014", 5926.0, 6058.0, 5876.4], 
  ["3/2013", 15.0, 0.0, 0.0], 
  ["4/2013", 15.0, 0.0, 0.0]]
  </code></pre>
  
  <p>I want to sort the array based on first element, first element of each array presents the week no in year(i.e. "2/2014" means 2nd week in 2014, which is greater than "50/2013") 
  the result will be like this</p>
  
  <pre><code>["3/2013", 15.0, 0.0, 0.0], 
  ["4/2013", 15.0, 0.0, 0.0],
  ["5/2013", 20.0, 6.0, 6.0], 
  ["7/2013", 73.0, 66.0, 66.0], 
  ["50/2013", 11530.0, 12625.27, 12087.75], 
  ["2/2014", 5926.0, 6058.0, 5876.4], 
  ]
  </code></pre>
  
  <p>I tried with this one </p>
  
  <pre><code>a.sort{|a,b| a[0].split('/')[1].to_i &lt;=&gt; b[0].split('/')[1].to_i  &amp;&amp; a[0].split('/')  [0].to_i &lt;=&gt; b[0].split('/')[0].to_i}
  </code></pre>
  
  <p>but it does not help. I am new in ruby and rails. Can anyone please help me to solve my problem.</p>