From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id EEF1D229AE for ; Sat, 20 Jan 2024 06:14:10 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1705727650; b=mMdHxTbaxBLV8Zu1o4cOzLha2XPEunS3FLKedXcHgJwURziU2Zfz6vcSxFP7JJUpo8j2wGrQVG GvJxx4+xOQSES51fvf4r/r0FrYuGcjc5jWkINI0J7ivHeNuPyI/N9ruQyM9+sSpxcOQGjMJ5xz 7TTNNZbI2FUCll2kOhUXR51+PGFDISVaSaOKw5/4OFpsOhL5rYBg5H43wfchFHQp0QYUF6G4lp PrUNM1s/JFuxnwS2oCx/zGU1Pd5HX/D6lpkSwiatRLclY1lkkXFPuBkMSwTMzKY/wcXEtWyQGq C/AVF97fs7ppbvEqcUrCljVr5Ny74J+9MDf+jC1s+JHJFg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-lj1-f175.google.com) smtp.remote-ip=209.85.208.175; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1705727650; bh=keFwbFaF1fT94zulQhysHzz+o30ytHjdPgMKL7oqrc4=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=R8XHxvag/OUO7bctgfZU/8LSWdtdB4YqLF9qmLl6PaI6W0BtOxXuNRcDgxgKX88JgfadXVr9Ot OcWKo8oPbe209AqdqskFG8a7mROl+LZZDb9Bs/AkAbLFFGENyKLnsez9YqZRl/yLD7qqowL2F+ MxDBvmQRnRITCZbUEl0/TBiBcX2bWMgkvR8QWNiNIeCg8FnyTCQ3jMMz+f6wmW6TWPf7KQLu+E 3yF3sm8xEqiuuQWM3IJtMhMvvPpOd/+OwXbSqK5lZyzfLFBAMWji//QgVk1tTNRPDGVL613MPM SE3ltT/EuKcqjFcZcao6p2NiUSeewm2g+1hx4A2H2NnPcQ==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:To:Subject:Message-ID: Date:From:In-Reply-To:References:MIME-Version:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=QpmwZl2TvAnEkqZZmKKncgUdgbnK3RXyEZ1momvi1fk=; b=mGFTZGVZYDq9J+7+R6XLYCDaHl kmYJ1MHL4V3VyEYCCkrbBkQNqJ0L66P8tcF2KkcajOItVHLRaXE3NecpOooacxoz1EsOwuuVYFcp1 24fDXPAWjGcEX7Evap4d08CtyG1dZtjaTGWlRqrSeyJCSjfTLnVK8k1pT6hZ8ueYB8DdUpFoI6R2v aEhFlcVBb/kltak0SHrpZGdZQwWNYVJY+iDokZ98rdrTePVVuwpIzXzoDOnTtLaTsDSm/bXG0UOP7 tHO/gfxpfJILVnIf+o67pRScWmC6ztXyuqAAJqczOijMEfWLXYC26QAuG1Z7DPtUvW9B1ts96qpZ4 QGv/RAfg==; Received: by zero.zsh.org with local id 1rR3gI-000D70-9Q; Sat, 20 Jan 2024 05:14:10 +0000 Authentication-Results: zsh.org; iprev=pass (mail-lj1-f175.google.com) smtp.remote-ip=209.85.208.175; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-lj1-f175.google.com ([209.85.208.175]:58854) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1rR3fe-000Cmf-1M; Sat, 20 Jan 2024 05:13:32 +0000 Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2cd46e7ae8fso18662321fa.1 for ; Fri, 19 Jan 2024 21:13:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705727608; x=1706332408; darn=zsh.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=QpmwZl2TvAnEkqZZmKKncgUdgbnK3RXyEZ1momvi1fk=; b=J4P7W6ei/9p10SNgF+3JnzOBAm6PdyaBr4TbqScW9+uq1j0SuER3mqr/W4wANAC4fO sFRoliVmFTFz223qHy050pjJr+/Qw1ALYciNamwpbM27DEYvwIvP5XsNDzofYo511R2D oaNjAat+yPoPE118FFqjcu/DC96r3JeneFqNoLldmIvZ3u51JCM1YWc1KkSTgGTBedpv 567WnHwoZ1dFgq5O9JxMGVwAmHu5UrTZ6XXpyOEEaw6XbIkbUp3/vCNinteO4q+ELqaH jnZrbOAB9bTHJ3j/ffZ0nzg7YKDWzSUF2/6wP9C1KKEevXLwVXUttVxmWe57ig+guF87 bqFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705727608; x=1706332408; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QpmwZl2TvAnEkqZZmKKncgUdgbnK3RXyEZ1momvi1fk=; b=UyXg5c4mIuuaD1XgIv55vdm2lcm757nH67WgSAGmX1tv9DOI12OQAtcRQHPdG2+qzD /PG+U4Qi+QXgC8tiGO41cWZtwDsxD3cx7PZw8cX663V2G8rJHrO49PQQpwKIfiGq427b jneyzv4L/ngRO9JysAPtu5lvakV09u3MDc8b7oCzBKQg+H1Rw6Y1vLilyxpFNl/vmWLe ehEnwVnKzj6YiH3jOImH6xJk/Veo9MSPmEh6E1g/HYC6eeSqVTjQ/4BXXdAWJTx68Mbf nH2XOK722f8vgarlXA9RrpC4Z9lwvoFByO7UiKi9Sn8oIC60gErmyTAo+uDrxTcsVpSG XvXw== X-Gm-Message-State: AOJu0Yw07jWIND2pNp59eA2lwNuaU/7E/GY2aBXaaw9gsYtOPqa7Hk5Z rEYYIunY/xUljMqmjbFGNA4W2oJPk0jWjupi0LwS2vxZA8UHtP5ieUj5jUOtQ+eR6rgxhhjt2Ti F95qPohiKe2S/G7p7PiiYzpEnMr6He1Mj X-Google-Smtp-Source: AGHT+IEeqDctQBV90CM/ArONHVMXTJoEYK371gS7+S0A8p7M+9LFpW5tqS55QyqzdA7pXGBF69ciBKb4aRyE0PVt2jM= X-Received: by 2002:a05:651c:1503:b0:2cd:d081:e7ab with SMTP id e3-20020a05651c150300b002cdd081e7abmr218169ljf.88.1705727607841; Fri, 19 Jan 2024 21:13:27 -0800 (PST) MIME-Version: 1.0 References: <8e648e57-3ee3-4b70-b95b-bb1475b9c760@gmx.com> In-Reply-To: <8e648e57-3ee3-4b70-b95b-bb1475b9c760@gmx.com> From: "Mark J. Reed" Date: Sat, 20 Jan 2024 00:13:15 -0500 Message-ID: Subject: Re: Associative array sorting To: zsh-workers@zsh.org Content-Type: multipart/alternative; boundary="000000000000262854060f59a890" X-Seq: 52491 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: --000000000000262854060f59a890 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable It sounds good, but *a* applies to indexes, not keys, and those aren't the same thing. Mind, I think that it would be good if, at least for purposes of expansion flags, indexes and keys *were* unified, so e.g. *k* on a regular array would return an array of indexes, and *kv* would interleave indexes with values (like Python enumerate), etc. But that's not the case today. On Fri, Jan 19, 2024 at 11:45=E2=80=AFPM Eric Cook wrote: > On 1/19/24 14:18, Bart Schaefer wrote: > > I was just looking at this in the manual -- > > > > a > > Sort in array index order; when combined with 'O' sort in reverse > > array index order. Note that 'a' is therefore equivalent to the > > default but 'Oa' is useful for obtaining an array's elements in > > reverse order. > > > > Like (o), (a) applies after the param is turned into an ordinary > > array, so "equivalent to the default" kind of gets us off the hook, > > but this would be the obvious place to attach sorting the associative > > array by key rather than by raw hash traversal. > > > > Sounds like a good idea to me. > > --=20 Mark J. Reed --000000000000262854060f59a890 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
It sounds good, but a applies to indexes, not keys,= and those aren't the same thing. Mind, I think that it would be good i= f, at least for purposes of expansion flags, indexes and keys were u= nified, so e.g. k on a regular array would return an array of indexe= s, and kv=C2=A0would interleave indexes with values (like Python enu= merate), etc. But that's not the case today.=C2=A0

=
On Fri= , Jan 19, 2024 at 11:45=E2=80=AFPM Eric Cook <llua@gmx.com> wrote:
On 1/19/24 14:18, Bart Schaefer wrote:
> I was just looking at this in the manual --
>
> a
>=C2=A0 =C2=A0 =C2=A0 =C2=A0Sort in array index order; when combined wit= h 'O' sort in reverse
>=C2=A0 =C2=A0 =C2=A0 =C2=A0array index order.=C2=A0 Note that 'a= 9; is therefore equivalent to the
>=C2=A0 =C2=A0 =C2=A0 =C2=A0default but 'Oa' is useful for obtai= ning an array's elements in
>=C2=A0 =C2=A0 =C2=A0 =C2=A0reverse order.
>
> Like (o), (a) applies after the param is turned into an ordinary
> array, so "equivalent to the default" kind of gets us off th= e hook,
> but this would be the obvious place to attach sorting the associative<= br> > array by key rather than by raw hash traversal.
>

Sounds like a good idea to me.



--
Ma= rk J. Reed <mar= kjreed@gmail.com>
--000000000000262854060f59a890--