help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Sorting on compound keys?


From: Stefan Monnier
Subject: Re: Sorting on compound keys?
Date: Wed, 28 Mar 2012 19:16:12 -0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

>> sometimes I want to sort unified diffs of CSV files (sepa-
>> rated by tabs (here: \t)):
>> 
>> | +A 1\t1\tx
>> | +A 1\t2\ty
>> | +B 2\t3\tz
>> | -A 1\t1\tx
>> | -B 2\t2\ty
>> | -B 2\t3\tz
>> 
>> by the second column, then the first column, then "+" vs.
>> "-". Unfortunately, it seems that sort-regexp-fields doesn't
>> allow more than one match field as a key.

IIUC you can do that by sorting several times: First call
sort-regexp-field on the +/-, then call it for the first column and
finally call it one last time for the second column.
This should work because the sort should be stable (the relative
ordering of equal keys is unaffected by the sort).


        Stefan


reply via email to

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