From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.devel Subject: Re: Human-readable file sorting Date: Sat, 20 Feb 2016 22:45:31 +1100 Message-ID: <87oabbli5g.fsf@gnus.org> References: <87povs41xg.fsf@gnus.org> <87bn7c3yms.fsf@gnus.org> <83si0npxtn.fsf@gnu.org> <87si0nlirx.fsf@gnus.org> <8360xjpq91.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1455968779 8895 80.91.229.3 (20 Feb 2016 11:46:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 20 Feb 2016 11:46:19 +0000 (UTC) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Feb 20 12:46:10 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aX5zF-0001uS-LJ for ged-emacs-devel@m.gmane.org; Sat, 20 Feb 2016 12:46:09 +0100 Original-Received: from localhost ([::1]:60278 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aX5zE-0007zU-S6 for ged-emacs-devel@m.gmane.org; Sat, 20 Feb 2016 06:46:08 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53529) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aX5zA-0007zL-Ux for emacs-devel@gnu.org; Sat, 20 Feb 2016 06:46:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aX5z7-0002PA-OX for emacs-devel@gnu.org; Sat, 20 Feb 2016 06:46:04 -0500 Original-Received: from hermes.netfonds.no ([80.91.224.195]:47967) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aX5z7-0002P4-Hj; Sat, 20 Feb 2016 06:46:01 -0500 Original-Received: from cpe-60-225-211-161.nsw.bigpond.net.au ([60.225.211.161] helo=mouse) by hermes.netfonds.no with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1aX5yj-0003Mf-8F; Sat, 20 Feb 2016 12:45:37 +0100 In-Reply-To: <8360xjpq91.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 20 Feb 2016 13:36:58 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) X-MailScanner-ID: 1aX5yj-0003Mf-8F MailScanner-NULL-Check: 1456573539.63751@9cqAeCaqMKC+GngMCVJHjw X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.224.195 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:200302 Archived-At: Eli Zaretskii writes: >> > Please don't call that function `file-string-lessp', or anything that >> > has "file" in it. This sorting order has nothing to do with files. >> >> Well, this is the function that's supposed to sort file names in the >> order requested by the user > > I think it's supposed to sort strings while treating numeric parts of > them specially. Its usage domain is wider than just file names. No no. This is the function that all Emacs things that want to sort file names should use. The definition of that function will be just (if some-user-setting (string-lessp ...) (logical-string-lessp ...)) >> Hm, interesting... >> >> (sort '("11" "12" "1 1" "1 2" "1.1" "1.2") 'string-collate-lessp) >> => ("11" "1 1" "1.1" "12" "1 2" "1.2") > > You will see that 'ls' in a UTF-8 locale does the same. Huh, I never noticed: larsi@mouse:/tmp/zot$ echo $LANG en_US.UTF-8 larsi@mouse:/tmp/zot$ ls 1* 10 11 1.1 12 But: larsi@mouse:/tmp/zot$ ls foo* foo12.txt foo1.txt foo2.txt Sorting is hard! -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no