In one answer I collected field values and used them as key of two associative arrays.
awk '{a[$2]++;b[$2]++}
END {
for(i in a) printf "a : %s\n", i ;
for(i in b) printf "b : %s\n", i
}' some_file.txt
I assumed the keys of those two arrays will be accessed in the same order, since they are exactly the same set.
The GNU Awk User's Guide describes the behaviour of awk as below:
The order in which elements of the array are accessed by this statement is determined by the internal arrangement of the array elements within
awk
and in standardawk
cannot be controlled or changed.
So I understand the order can't be predicted, but is that to say it won't be deterministic and context independent?
Update. In view of the accepted answer, I edited my referenced answer to fit the behaviour of awk
.