From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.bugs Subject: bug#45361: 28.0.50; tabulated-list-mode: should be sorting by specified sort function Date: Tue, 22 Dec 2020 12:43:55 +0300 Message-ID: References: <87v9cu9og8.fsf@gmx.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40678"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/2.0 (3d08634) (2020-11-07) Cc: 45361@debbugs.gnu.org, 45361-done@debbugs.gnu.org To: Stephen Berman Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Dec 22 10:50:12 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kreJ2-000ASx-9C for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 22 Dec 2020 10:50:12 +0100 Original-Received: from localhost ([::1]:46108 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kreJ1-0003ou-3j for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 22 Dec 2020 04:50:11 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54782) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kreIs-0003oM-BU for bug-gnu-emacs@gnu.org; Tue, 22 Dec 2020 04:50:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:37426) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kreIs-0003Ni-3s for bug-gnu-emacs@gnu.org; Tue, 22 Dec 2020 04:50:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kreIr-00046L-QT for bug-gnu-emacs@gnu.org; Tue, 22 Dec 2020 04:50:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Jean Louis Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 22 Dec 2020 09:50:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45361 X-GNU-PR-Package: emacs Original-Received: via spool by 45361-submit@debbugs.gnu.org id=B45361.160863054515648 (code B ref 45361); Tue, 22 Dec 2020 09:50:01 +0000 Original-Received: (at 45361) by debbugs.gnu.org; 22 Dec 2020 09:49:05 +0000 Original-Received: from localhost ([127.0.0.1]:48970 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kreHw-00044J-C5 for submit@debbugs.gnu.org; Tue, 22 Dec 2020 04:49:04 -0500 Original-Received: from stw1.rcdrun.com ([217.170.207.13]:53035) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kreHt-00043b-3T; Tue, 22 Dec 2020 04:49:02 -0500 Original-Received: from localhost ([::ffff:41.202.241.37]) (AUTH: PLAIN securesender, TLS: TLS1.2,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA id 0000000000011FE1.000000005FE1C105.0000439F; Tue, 22 Dec 2020 02:48:52 -0700 Content-Disposition: inline In-Reply-To: <87v9cu9og8.fsf@gmx.net> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:196568 Archived-At: * Stephen Berman [2020-12-22 12:32]: > On Tue, 22 Dec 2020 08:13:50 +0100 Jean Louis wrote: > > > PROBLEM: > > > > The variable `tabulated-list-format' provides for programmer > > option to sort columns and I would like to sort number as > > strings "12" as numbers, not as strings. I do not know how to > > properly provide the sorting function to `tabulated-list-format' so > > that it works when actually sorting. > [...] > > Then I would like to use the function `string-collate-lessp' as that > > seem to understand how numbers should be compared. > > > > For example this is giving me correct result: > > > > (sort '("121" "117" "1") 'string-collate-lessp) => ("1" "117" "121") > > But: > > (sort '("21" "117" "1") 'string-collate-lessp) => ("1" "117" "21") > > So string-collate-lessp doesn't do what it seems you want. Oh, I missed to see that. That is the problem. > Actually, tabulated-list-print does call my-sort via > tabulated-list--get-sorter. Anyway, buffer-menu.el has the function > `tabulated-list-entry-size->', which with a small adjustment does what > you seem to want. Try this: > > (defun my-tabulated-list-entry-size-> (entry1 entry2) > (> (string-to-number (aref (cadr entry1) 0)) > (string-to-number (aref (cadr entry2) 0)))) That is what I missed to see, thank you for references and your help. Now it works well. Jean P.S. Closing it as it is not a bug.