title: Linux command to sort according to second word/character
body: <p>I have a linux file whose content is as below:</p>
  
  <pre><code>hey this 
  is just
  sample file
  </code></pre>
  
  <p>I want to :</p>
  
  <p><strong>1.</strong>  sort the three lines according to the second word so the output should be :</p>
  
  <pre><code>sample file
  is just
  hey this 
  </code></pre>
  
  <p><strong>2.</strong>  sort the three lines according to the second character of second line, so the output would be :</p>
  
  <pre><code>hey this 
  sample file
  is just
  </code></pre>
  
  <p>Is there anyway i can run a perl/unix command on command line(doesnt matter using pipes)?</p>