Gawk: PROCINFO["sorted_in"] does not sort my numerical array values

Hi,

PROCINFO seems to be a great function but I don't manage to make it works.

input:

B,A,C
B
B,B

As an example, just want to count the occurence of each letter across the input and sort them by decreased order.

Wanted output:

B 4
A 1
C 1

When I use this command, the PROCINFO does not have any effect:

echo -e "B,A,C\nB\nB,B" | gawk '{a=split($0,b,","); for(i=1; i<=a; i++){count[b]++}}END{PROCINFO["sorted_in"]="@_val_num_desc"; for(k in count){print k FS count[k]}}'

I get this output:

A 1
B 4
C 1

Could someone explain me what I am doing wrong?

Thanks !

Try "@val_num_desc"

1 Like

Sorry, I am stupid...

No "_" between "@" and "val"

Sorry again

Note: I had to upgrade gawk to version 4 to get PROCINFO working

1 Like

Thanks for letting us know

So - problem persists? Solved?

EDIT: Seems solved by now... Methinks part of the problem was the gawk version...