From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?ISO-8859-1?Q?Andreas_R=F6hler?= Newsgroups: gmane.emacs.help Subject: Re: Sorting on compound keys? Date: Thu, 26 May 2011 08:28:10 +0200 Message-ID: <4DDDF2FA.2050201@easy-emacs.de> References: <4DDC9A94.3080903@easy-emacs.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Trace: dough.gmane.org 1306391308 27672 80.91.229.12 (26 May 2011 06:28:28 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 26 May 2011 06:28:28 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu May 26 08:28:22 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QPU3R-0000Pg-Cn for geh-help-gnu-emacs@m.gmane.org; Thu, 26 May 2011 08:28:21 +0200 Original-Received: from localhost ([::1]:47921 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QPU3Q-0001Nt-VI for geh-help-gnu-emacs@m.gmane.org; Thu, 26 May 2011 02:28:20 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:41038) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QPU3M-0001NW-4U for help-gnu-emacs@gnu.org; Thu, 26 May 2011 02:28:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QPU3L-0002jn-0E for help-gnu-emacs@gnu.org; Thu, 26 May 2011 02:28:16 -0400 Original-Received: from moutng.kundenserver.de ([212.227.17.9]:63595) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QPU3K-0002jL-Ld for help-gnu-emacs@gnu.org; Thu, 26 May 2011 02:28:14 -0400 Original-Received: from [192.168.178.27] (brln-4d0c331d.pool.mediaWays.net [77.12.51.29]) by mrelayeu.kundenserver.de (node=mrbap2) with ESMTP (Nemesis) id 0Mc9Nn-1Q6zhE1VeZ-00J7oh; Thu, 26 May 2011 08:28:12 +0200 User-Agent: Mozilla/5.0 (X11; U; Linux i686; de; rv:1.9.2.17) Gecko/20110414 SUSE/3.1.10 Thunderbird/3.1.10 In-Reply-To: X-Provags-ID: V02:K0:cFOche443HTSId0L4ruhXbjOtcqcEiJ4u7u1n28ZX6K vFkr8P/umEY2bGiauLgYSaOGPf6xEGX2UyzfM7j2x/GMtJSmn6 GCaMc+nOvMoky/3G+QU46jI3LHyFHkXykGkVjhAVQQcfmKQEn6 uH1FlNZDJKq+rlI/D0z27a1g3C7FEl3xk9U9TKgfV122vhBJ/t /YUCBL2U42zVlkf2DdLZi0FydalaT8+mIlgtYKlr34= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.227.17.9 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:81247 Archived-At: Am 26.05.2011 00:08, schrieb Tim Landscheidt: > Andreas Röhler wrote: > >>> 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. sort-fields >>> doesn't work either as it requires the fields to be sur- >>> rounded by white space (no "+" vs. "-") and doesn't allow >>> white space inside the fields. > >>> Is there any function in vanilla Emacs (23.1.1) that I >>> missed? I looked at pimping sort-regexp-fields, but it seems >>> to me that sort-subr would have to be rewritten from scratch >>> to achieve sorting on compound keys. > >> last time I looked into that feature was missing indeed. >> However, didn't look for a need of re-write from the >> scratch, just to extend to existing routine - ie. introduce >> one or more levels of sorting. > > I remember our discussion in de.comp.editoren :-), but as I > read sort-subr it is hard-coded that the sort key is one > literal, continuous part of the buffer as sort-lists is a > list of buffer positions. > > Tim > > > sort-subr takes functions to determine the fields to sort. As for the functions as arguments, maybe have a look at `ar-th-sort' in thingatpt-utils-base.el https://code.launchpad.net/s-x-emacs-werkstatt/ Cheers, Andreas