[Top][All Lists]

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

sort/uniq/join: key-comparison code consolidation

From: Assaf Gordon
Subject: sort/uniq/join: key-comparison code consolidation
Date: Thu, 14 Feb 2013 18:07:51 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.4) Gecko/20120510 Icedove/10.0.4


( new thread for previous topic ) .

The attached patch contains:
1. src/key-spec-parsing.{h,c} - key comparison code, previously in sort.c

2. uniq - now supports "--key" (multiple keys, too).
Same as before, but rebased against 8.21.
Supported orders:
  -k1,1  = ascii
  -k1b,1 = ignore-blanks
  -k1d,1 = dictionary
  -k1i,1 = non-printing
  -k1f,1 = ignore-case
  -k1n,1 = fast-numeric
  -k1g,1 = general-numeric
  -k1M,1 = month
also supports user-specified delimiter (default: white-space).

Related discussions:

3. sort - same functionality as before, but key-comparison code extracted to a 
different file.

4. join - internally uses the key-comparison code.
Does not support the "--key" parameter (uses the standard -j/-1/-2),
but accepts new arguments that affect joining order:
 -r --reverse
 -n --numeric-sort
 -d --dictionary-order
 -g --general-numeric

Related discussions:

As an option, perhaps we can support new "-k" that will be like "-j" but allow 
specificity options
(e.g. "-k1nr" will be equivalent to "-j 1 --numeric --reverse").

It'll be easy to add human-numeric-sort/version-sort to join/uniq, but I'm not 
sure if they make sense.


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

reply via email to

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