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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# From: j.eh@mchsi.com
# March and April 2010
BEGIN {
print "--- test1 ---"
a[1] = b[3] = 5
a[2] = b[2] = "3D"
a[3] = b[1] = 10
asort(a)
asort(b)
for (i = 1; i <= 3; ++i)
printf(" %2s %-2s\n", (a[i] ""), (b[i] ""))
delete a
delete b
}
BEGIN {
print "--- test2 ---"
a[100] = a[1] = a["x"] = a["y"] = 1
PROCINFO["sorted_in"] = "@ind_num_asc"
for (i in a)
print i, a[i]
delete a
}
BEGIN {
print "--- test3 ---"
a[100] = a[1] = a["x"] = 1
PROCINFO["sorted_in"] = "@ind_num_asc"
for (i in a)
print i, a[i]
delete a
}
BEGIN {
print "--- test4 ---"
a[0] = a[100] = a[1] = a["x"] = 1
PROCINFO["sorted_in"] = "@ind_num_asc"
for (i in a)
print i, a[i]
delete a
}
BEGIN {
print "--- test5 ---"
a[""] = a["y"] = a[0] = 1
PROCINFO["sorted_in"] = "@ind_num_asc"
for (i in a)
print i, a[i]
delete a
}
BEGIN {
print "--- test6 ---"
a[2] = a[1] = a[4] = a["3 "] = 1
PROCINFO["sorted_in"] = "@ind_num_asc"
for (i in a)
print "\""i"\""
delete a
}
BEGIN {
print "--- test7 ---"
n = split(" 4 \n 3\n3D\nD3\n3\n0\n2\n4\n1\n5", a, "\n")
for (i = 1; i <= n; i++)
b[a[i]] = a[i]
print "--unsorted--"
PROCINFO["sorted_in"] = "@unsorted"
for (i in b)
print "|"i"|"b[i]"|"
print "--asc ind str--"
PROCINFO["sorted_in"] = "@ind_str_asc"
for (i in b)
print "|"i"|"b[i]"|"
print "--asc val str--"
PROCINFO["sorted_in"] = "@val_str_asc"
for (i in b)
print "|"i"|"b[i]"|"
print "--asc ind num--"
PROCINFO["sorted_in"] = "@ind_num_asc"
for (i in b)
print "|"i"|"b[i]"|"
print "--asc val num--"
PROCINFO["sorted_in"] = "@val_num_asc"
for (i in b)
print "|"i"|"b[i]"|"
}
|