On Tue, 1 Sep 2020, Allin Cottrell wrote:
On Tue, 1 Sep 2020, Sven Schreiber wrote:
> Hi,
>
> I wanted to do 'dataset sortby x', where x is a string-valued series.
> But this just used the underlying integer codes and thus didn't do
> anything. Is there a way to sort lexicographically using the string values?
Well, naturally there is, via hansl. But if you mean a built-in command or
function the answer's No. However, it seems that plain "dataset sortby"
should probably do that by default (or at least in response to an option). A
nice little project for someone ;-)
Now done in git. Trivial example:
<csv>
x,y,z
1,B,7
2,D,6
3,A,5
4,A,4
5,C,3
6,B,2
7,D,1
</csv>
<hansl>
set verbose off
open strsort.csv -q
print -o
dataset sortby y
print -o
</hansl>
<output>
x y z
1 1 B 7
2 2 D 6
3 3 A 5
4 4 A 4
5 5 C 3
6 6 B 2
7 7 D 1
x y z
1 3 A 5
2 4 A 4
3 1 B 7
4 6 B 2
5 5 C 3
6 2 D 6
7 7 D 1
</output>
Allin