From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Sam Steingold Newsgroups: gmane.emacs.devel Subject: lexicographic list comparison Date: Fri, 09 Sep 2022 15:27:46 -0400 Message-ID: Reply-To: sds@gnu.org Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36784"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (darwin) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Sep 09 21:28:38 2022 Return-path: Envelope-to: ged-emacs-devel@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 1oWjg5-0009RS-Ke for ged-emacs-devel@m.gmane-mx.org; Fri, 09 Sep 2022 21:28:37 +0200 Original-Received: from localhost ([::1]:49668 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oWjg4-0000Uh-74 for ged-emacs-devel@m.gmane-mx.org; Fri, 09 Sep 2022 15:28:36 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52612) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oWjfR-0008Ee-Bk for emacs-devel@gnu.org; Fri, 09 Sep 2022 15:27:57 -0400 Original-Received: from mail-qk1-x72e.google.com ([2607:f8b0:4864:20::72e]:33516) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oWjfK-0007kG-GZ; Fri, 09 Sep 2022 15:27:57 -0400 Original-Received: by mail-qk1-x72e.google.com with SMTP id h28so1979195qka.0; Fri, 09 Sep 2022 12:27:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:message-id:date:mail-followup-to:reply-to :return-receipt-to:user-agent:subject:to:from:sender:from:to:cc :subject:date; bh=FwYtUg1rBB0zmlPNPB6iElL186fTGwamgdamilxKdAI=; b=YAtlP59clKgRJOcOOElilagvy1CpEwyPcgT3pUQqsIefxxnWy1ZA+llpzCiCqB22tj tE53pwm7nlQoSND4FGNZryffy/IBDCo1CphlfJABBHDLM2fdtYfWu4rJb/fEGDzT3d42 VYn/s/D/Ci+j3VOgGcdoT9rW1r9idjcJsSMBz7SNL57NSLGMgId2D77RpjlZFowebMWM PwmtdAPc01xE9YrhsDhHl4akVEZFZeQVsTnvdDtOX0hx22hmQWFDA1JR4s/N9Nztme6l LRByb/xl4NORWuZ+xsH4O88v+Z42aJfxC8DakX3pqEzwQOudZ9vm2BGXpsdE8k3984t1 BZyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:mail-followup-to:reply-to :return-receipt-to:user-agent:subject:to:from:sender :x-gm-message-state:from:to:cc:subject:date; bh=FwYtUg1rBB0zmlPNPB6iElL186fTGwamgdamilxKdAI=; b=nVJFA4kJ61UCgsFyACH9WrLywJsQXiOJgxZQtFuvW/cDbEv08slyV3wFqM4SKTm10u R9V6uO/1WDjUuxqOBziXb7gFZGRX89sHcOXSViH13ZatAA+g6mT3SXaU91buz48GyzX2 25DBc65/RvOdORbGAU4KBzc3uroAG4ztRHDNdM+n4DOsWJzKHdO6K59tHBeeaL/vgImm d6EzDMZ9zushQufletqGF9f1LOqGNdmI2OOcPfW9nKuKaYnCGPtz947XHE4kStE/e8Aw JnYX7OyXBdt2RqR16DEBgejE12YiO1BpHDpWk3wMoLpiMi6vX/7fm7Tk0ChC2xFuIt27 DHLw== X-Gm-Message-State: ACgBeo0cd7lxwxQe99EPkd6sVvrdTXy3b4w1GM2RQJ/gwiyIOw3O+5iU EuMG2R5KgzAPDDCSQuLtOhVGyTWkK7nX X-Google-Smtp-Source: AA6agR4c5tdnruZeFqJ7C90nDz+jnOEVcd3lvRCAgWLDQlWpnQXiC8wh50pBxa/JJTwF1w3JndEsUw== X-Received: by 2002:a05:620a:4e4:b0:6be:8dd8:87e0 with SMTP id b4-20020a05620a04e400b006be8dd887e0mr11206241qkh.677.1662751668110; Fri, 09 Sep 2022 12:27:48 -0700 (PDT) Original-Received: from 3c22fb11fdab.ant.amazon.com (pool-108-30-23-113.nycmny.fios.verizon.net. [108.30.23.113]) by smtp.gmail.com with ESMTPSA id x10-20020a05620a448a00b006c08fddd081sm1176573qkp.75.2022.09.09.12.27.47 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 09 Sep 2022 12:27:47 -0700 (PDT) X-Attribution: Sam X-Disclaimer: You should not expect anyone to agree with me. Mail-Followup-To: emacs-devel@gnu.org Received-SPF: pass client-ip=2607:f8b0:4864:20::72e; envelope-from=sam.steingold@gmail.com; helo=mail-qk1-x72e.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:295093 Archived-At: Hi, What do you do when sorting a list of lists of numbers? There does not appear to be a standard comparison function like --8<---------------cut here---------------start------------->8--- (defun lexicographic-compare-lists (l1 l2 &optional lessp) "lexicographic list comparison" (unless lessp (setq lessp #'<)) (or (null l2) (null l1) (funcall lessp (car l1) (car l2)) (and (not (funcall lessp (car l2) (car l1))) (lexicographic-compare-lists (cdr l1) (cdr l2) lessp)))) --8<---------------cut here---------------end--------------->8--- [[[It appears that it is less critical for strings because one can do --8<---------------cut here---------------start------------->8--- (sort list-of-lists-of-strings (lambda (l1 l2) (string< (string-join l1) (string-join l2)))) --8<---------------cut here---------------end--------------->8--- instead of --8<---------------cut here---------------start------------->8--- (sort list-of-lists-of-strings (lambda (l1 l2) (lexicographic-compare-lists l1 l2 #'string<))) --8<---------------cut here---------------end--------------->8--- even though it conses for each comparison(!)]]] Or maybe sorting lists of lists is just such a rare op that no one has ever encountered it before me? ;-) Thank you. -- Sam Steingold (https://aphar.dreamwidth.org/) on darwin Ns 10.3.2113 https://lastingimpactpsychology.com https://steingoldpsychology.com https://ij.org/ https://honestreporting.com https://memri.org You do not have time or money to sue anyone rich enough to be worth suing.