[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-gawk] Help ourself
From: |
Budi |
Subject: |
[bug-gawk] Help ourself |
Date: |
Tue, 23 Apr 2019 07:07:06 +0700 |
We have facts that
$ export LC_ALL=C
$ cat f
2161
4321
6481
8641
10801
4321
8641
12961
17281
21601
$ awk '{a[NR]=$0}END{ asort(a);for(;i++<NR;){ print a[i] }}' f
2161
4321
4321
6481
8641
8641
10801
12961
17281
21601
One would accept as it's a number sort
$ cat f
36829.00 37145.00 2161
36829.00 37145.00 4321
36829.00 37145.00 6481
36829.00 37145.00 8641
36829.00 37145.00 10801
36829.00 37145.00 4321
36829.00 37145.00 8641
36829.00 37145.00 12961
36829.00 37145.00 17281
36829.00 37145.00 21601
$ awk '{a[NR]=$0}END{ asort(a);for(;i++<NR;){ print a[i]}}' f
36829.00 37145.00 10801
36829.00 37145.00 12961
36829.00 37145.00 17281
36829.00 37145.00 21601
36829.00 37145.00 2161
36829.00 37145.00 4321
36829.00 37145.00 4321
36829.00 37145.00 6481
36829.00 37145.00 8641
36829.00 37145.00 8641
One would accept as it's a string sort
How to resolve this confusing processes ?