You have forgot to declare the local variables in printTop
. Try:
function printTop(n,array, i, tmpidx, j, num, indices) {
for (i in array)
tmpidx[sprintf("%12s", array[i]),i] = i
num = asorti(tmpidx,ind)
j=0
for (i=1; i<=num; i++) {
split(ind[i], tmp, SUBSEP)
indices[++j] = tmp[2] # tmp[2] is the name
}
for (i=num; i>num-n && i>0; i--)
print indices[i]"\t"array[indices[i]]
}
(Assuming you remove the NULL
in printTop(sizeTop,IPdstBytes,NULL);
. That is: call the function as printTop(sizeTop,IPdstBytes);
instead)