title: Sort an array of numbers in awk
body: <p>How can I sort an array of numbers in awk? Consider "sortNum.awk" :</p>
  
  <pre><code>{
      split($0,a," ")
      for (i in a) print a[i]
      print "####"
      asort(a)
      for (i in a) print a[i]
  }
  </code></pre>
  
  <p>Running with <code>echo "4 3 2 1" | awk -f sortNum.awk</code> gives</p>
  
  <pre><code>1
  4
  3
  2
  ####
  4
  1
  2
  3
  </code></pre>
  
  <p>I am using GNU Awk version 3.1.8.</p>