How to print an array in defined order in AWK 3.1.3 -


i googled , find out after awk 4.0 can print array in defined order putting procinfo["sorted_in"] command right before loop. example

    procinfo["sorted_in"] = "@ind_num_asc"     for( in array)           print i, array[i] 

in awk 4.0.2, works. however, tried in awk 3.1.3 environment, did not work. version of awk not support function? how achieve goal in awk 3.1.3?

just keep second array order numerical indices , keys first array values. can iterate through order in sequence , values of array:

for (i = 1; < length(order); i++) {   print order[i], array[order[i]] } 

when building order, may want check whether key present in array, prevent keys of array being shown multiple times.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -