sort associative array in awk - help?

Posted by Richard on Stack Overflow See other posts from Stack Overflow or by Richard
Published on 2010-03-16T21:37:13Z Indexed on 2010/03/16 21:41 UTC
Read the original article Hit count: 455

Filed under:
|
|
|

Hi all, I have an associative array in awk that gets populated like this...

chr_count[$3]++

When I try to print my chr_counts I use this:

for (i in chr_count) {
    print i,":",chr_count[i];
}

But not surprisingly, the order of i is not sorted in any way. Is there an easy way to iterate over the sorted "keys" of chr_count?

© Stack Overflow or respective owner

Related posts about awk

Related posts about associative