From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 0DjPLD7EVWGEVAAAgWs5BA (envelope-from ) for ; Thu, 30 Sep 2021 16:05:50 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id CBhnKD7EVWExVgAAbx9fmQ (envelope-from ) for ; Thu, 30 Sep 2021 14:05:50 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 2EF8A21DD9 for ; Thu, 30 Sep 2021 16:05:50 +0200 (CEST) Received: from localhost ([::1]:52044 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVwh3-0004KC-7f for larch@yhetil.org; Thu, 30 Sep 2021 10:05:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42782) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVwcQ-0007th-Qi for guix-patches@gnu.org; Thu, 30 Sep 2021 10:01:07 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:42019) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVwcQ-00030A-66 for guix-patches@gnu.org; Thu, 30 Sep 2021 10:01:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mVwcP-0000iv-Ra for guix-patches@gnu.org; Thu, 30 Sep 2021 10:01:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50878] [PATCH] union: Resolve collisions by stable-sort'ing them. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 30 Sep 2021 14:01:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50878 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Maxime Devos Cc: Attila Lendvai , Liliana Marie Prikler , 50878@debbugs.gnu.org Received: via spool by 50878-submit@debbugs.gnu.org id=B50878.16330104492752 (code B ref 50878); Thu, 30 Sep 2021 14:01:01 +0000 Received: (at 50878) by debbugs.gnu.org; 30 Sep 2021 14:00:49 +0000 Received: from localhost ([127.0.0.1]:53565 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mVwcD-0000iK-8T for submit@debbugs.gnu.org; Thu, 30 Sep 2021 10:00:49 -0400 Received: from eggs.gnu.org ([209.51.188.92]:37498) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mVwcA-0000i3-W6 for 50878@debbugs.gnu.org; Thu, 30 Sep 2021 10:00:47 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:47270) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVwc4-0002hZ-KA; Thu, 30 Sep 2021 10:00:40 -0400 Received: from [2001:660:6102:320:e120:2c8f:8909:cdfe] (port=60506 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVwby-00006w-PH; Thu, 30 Sep 2021 10:00:39 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20210928214044.437-1-attila@lendvai.name> <57f1435fd83da8c0e0acaef64d5f08e4ca7b3404.camel@gmail.com> <9ab183637e8cd645267a37ba0f05319f8b3c72ff.camel@telenet.be> Date: Thu, 30 Sep 2021 16:00:32 +0200 In-Reply-To: <9ab183637e8cd645267a37ba0f05319f8b3c72ff.camel@telenet.be> (Maxime Devos's message of "Thu, 30 Sep 2021 10:42:13 +0200") Message-ID: <87czoq40zj.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1633010750; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=Thqi5NVYjNMUXXxQWGhrr945j1nTP7pLK7avqmbja10=; b=WPsgwUOe2SS7YL+QRRl96+xKXAKsKZt8TTw0rkEU/OrFWPuht8G7/uIwe7A1EgcqUqaQ1L DGqmlC59YvZUkEn5okQs3jNb5qVXAXM6/Y+29m4VfA9VZqMNTdqk39zt0sqnZ8qsyA0jdh f+piOn1cNwFI/HDEkc08iBJd2sLMoHRjSDVye8tjeH0noOYMgzLFWVyDRLMo6JCQDinc24 cD4VH1qoh+TstoO9jwD8eI0ZCX1xC252psd3HfmST2QBy948Bsuw5OQ212dl2RQ+TRDOgn T/4voutNx9oAm3VRvpZ0SzDWF66YJM8bT1bgfqiLtyeXipAqMZMxmAnN2QP4+g== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1633010750; a=rsa-sha256; cv=none; b=ucP9aGI3n2gMz+bQqGk9xFatX4zG9z3LOkx7UkwZtR34wJ5w8Nys8Q1AQhQy+AAtffrD6e Ub7eSQmvl6Dc8RfvE3DZRxWdFLJIW8dD7aLTmgRHFu+7z7/1ULsUVIlCmQANNRNxaJlffV req55Rwo10QVtp5jN8XF2BMbvnWm+u3N6U+fiSMW/iAnz/3Wh99S1F12oRtbFSuJXK73NK IKp+vyEPjpgXfJ+OO3etWyH64pSeC8e5FGZrC2amiYrocJhF1b5+K1TGWFDz+EaFL37Gv8 hvZDqfBLAIfFMj9qpYMZgzP+kYfcqSejHlcZhVbQ7BmA4QDEgObWhhFiEbMgBg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -1.40 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 2EF8A21DD9 X-Spam-Score: -1.40 X-Migadu-Scanner: scn0.migadu.com X-TUID: Zao6O0j15oj6 Hi, Maxime Devos skribis: > Attila Lendvai schreef op do 30-09-2021 om 08:10 [+0000]: >> > > - (let* ((original-files (list->vector files)) >> > > - (count (vector-length original-files)) >> > > - (stripped-files (vector-map (lambda (_ el) >> > > - (strip-store-file-name el)) >> > > - original-files)) >> > > - (indices (vector-unfold values count))) >> > >=20 >> > > - (stable-sort! indices >> > > - (lambda (a b) >> > > - (string> (vector-ref stripped-files a) >> > > - (vector-ref stripped-files b)))) >> > > - (vector-ref original-files (vector-ref indices 0)))) >> >=20 >> > Instead of stable-sort!-ing the indices of a vector, what about stable- >> > sort!-ing (map strip-store-file-name original-files) in more or less >> > one go? >>=20 >> the hash also needs to be dropped from the path for sorting to be >> useful, but the return value must be the full path, hence the >> complexity with sorting the indices, pointing both to the full paths >> and the cut parts. > > You can replace the 'less' argument of 'stable-sort'. > Example sorting by the second character of a string: > > (sort '("za" "yb" "xc") (lambda (x y) > (char>? (string-ref x 1) > (string-ref y 1))))) > > IIUC, you would need to replace char>? by string> and string-ref > by strip-store-file-name. Agreed. I=E2=80=99d advice using this strategy rather than resorting to SRFI-43; it should have the desired effect. BTW, because TeX Live packages rely on =E2=80=98union-build=E2=80=99, this = patch triggers a lot of rebuilds, but we can try to squeeze it in the upcoming =E2=80=98core-updates-frozen=E2=80=99 rebuild. Thanks, Ludo=E2=80=99.