title: awk to find min and max of an array
body: <p>I have file that generates different IDs and count as shown below</p>
  
  <pre><code>prod1 13
  prod4 14
  prod5 14
  prod3 11
  prod2 8
  prod1 9
  prod3 16
  prod5 11
  prod2 9
  prod4 11
  prod1 16
  prod5 8
  prod3 16
  prod2 3
  prod4 1
  prod3 3
  prod2 1
  prod1 1
  prod5 3
  prod1 2
  prod4 78
  </code></pre>
  
  <p>I am trying to find an option to get the max and min for each product. </p>
  
  <p>Running the following awk script gives me the count and sum but I also need to track the min and max for each product.</p>
  
  <pre><code>awk '{ Prod[$1]++; sum[$1]+=$2 } END{ for (var in Prod) print var, "count", Prod[var], "and sum", sum[var]}'
  
  prod1 count 5 and sum 41
  prod2 count 4 and sum 21
  prod3 count 4 and sum 46
  prod4 count 4 and sum 104
  prod5 count 4 and sum 36
  </code></pre>
  
  <p>Is there a way to modify the awk array script to get the max and min values?</p>
  
  <p>Thanks!</p>