title: awk: function asorti never defined
body: <p>I'm wrting awk program and program needs to sort the "associative array"</p>
  
  <pre><code>{
      subj[$1]++  
  }
  END{
  
      n=asorti(subj, sorted)
      for(k=1;k&lt;=n;k++)
      {
          print(k" "sorted[k])
      }
  }
  </code></pre>
  
  <p>while exceuting with below cmd</p>
  
  <pre><code>$ awk -f prg.awk "subjects"
  </code></pre>
  
  <p>giving below error:</p>
  
  <p>awk: function asorti never defined</p>
  
  <p>[inputfile]</p>
  
  <pre><code>Phy
  Math
  Math
  Science
  Bio
  Phy
  </code></pre>
  
  <p>Operating system: ubuntu 16.04</p>
  
  <p>Excepted o/p</p>
  
  <pre><code>Bio 1
  Math 2
  Phy 2
  Science 1
  </code></pre>