bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-gawk] How awk keys are ordered?


From: Peng Yu
Subject: [bug-gawk] How awk keys are ordered?
Date: Tue, 20 Dec 2016 16:13:02 -0600

Hi, The following shows that awk hash keys are ordered numerically
whether the actual keys are actually numbers or strings. Does anyone
know when this assumption of ordering is true? Thanks.

~$ cat main1.awk
# vim: set noexpandtab tabstop=2:

BEGIN {
    for(i=1;i<=26;i++) {
        array[i]=1
    }
    for(i in array) {
        print i
    }
    for(i=1;i<=26;i++) {
        array["" i] =1
    }
    for(i in array) {
        print i
    }
}
~$ awk -f ./main1.awk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26


-- 
Regards,
Peng



reply via email to

[Prev in Thread] Current Thread [Next in Thread]