[Top][All Lists]

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

Re: uniq with sort-like "--key" support (now with sort and join)

From: Assaf Gordon
Subject: Re: uniq with sort-like "--key" support (now with sort and join)
Date: Wed, 13 Feb 2013 19:43:15 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.4) Gecko/20120510 Icedove/10.0.4

More updates:
The attached patch converts 'sort' and 'join' to use the key comparison 
functions in 'key-spec-parsing.c'.

Sort was straight-forward (as expected), mostly removing the duplicated code 
and moving some more functions to key-spec-parsing.c.

Join required a bit of trickery (explained in the code), the main change is the 
'keycmp()' function that now calls "keycompare()".

All tests pass for sort and join, but I suspect the join test-suite is not 

Join definitely needs more testing, but one immediate feature is join in 
reverse order (which already works):
## Input files
$ cat 
C 1
B 2
A 3
$ cat 
C 9
A 8

## Existing join
$ join -a 1 -a 2 -o auto -e . -j1 
C 1 9
A . 8
B 2 .
join: is not sorted: A 3
A 3 .

## new Join reverse
$ ./src/join --reverse -a 1 -a 2 -o auto -e . -j1 
C 1 9
B 2 .
A 3 8


Attachment: uniq_key6.patch.xz
Description: application/xz

reply via email to

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