Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125824 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 4D2541A00BD for ; Mon, 21 Oct 2024 13:29:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1729517508; bh=zJzhYZPZSbaqXwV3wpCxlOEQO+0AHU5/FfXxJtP0frg=; h=References:In-Reply-To:From:Date:Subject:To:From; b=TR7drnjVJDAgCY5w+E1zOGz3nBZvstJnFQpva9VP0BkC1cQrZvOkOvmn6Mt5JPD6H g1mDbfGjrNu1L0SoMzm1ZB2cLoGGgJ0VT7cqJCsP94dR0BjHXDMZNT7KkCt6wZBXUW 07TkScl9sMPEg/6T/7MKFUCerdfyhiRhRznZ4jHSwOSyToCQgSo34eKtpwBCn20XFn HrzRv2gA3Busu16iz780kMba13liE8pUDAgy8XxuNL3oeNBrk7C0GmOyHZhsdb78Dr rJxiR/9sFtv+3XiOYbmLvCNjcpjgtxK+rH2a88kYF3t7t1kKhN4qYOS/xNfs16CMds 25VZhPwI9t0vw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 27B2F18006D for ; Mon, 21 Oct 2024 13:31:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-qk1-f176.google.com (mail-qk1-f176.google.com [209.85.222.176]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 21 Oct 2024 13:31:47 +0000 (UTC) Received: by mail-qk1-f176.google.com with SMTP id af79cd13be357-7b1467af9dbso331623485a.0 for ; Mon, 21 Oct 2024 06:29:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729517363; x=1730122163; darn=lists.php.net; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=pOIQy5ysT8d///wbhEAnPyitbzLm0NU4UMAQOTN7XLc=; b=Z7xViF5NQLYS5S8Y+O7tL84jO1RNS6thBhabjvkMW4yLQ5fy2P8VJtS2s7KXZkWc6p zCqmQCU7GkWK3FCTybRVwh1M5ezMDioDfrPXnb+Qy9xrxLODeJ46Ila8MMORngK8GdBd pMs+0Jok5OIj5DDPXiP778esozxwN4tIAGUje+UAiroyNkAtcAdTQqNCOxOiEMzrO9Il /Mv7i/ySpbRAsTqaSwHPrE8KuQ8716zKqaWd58qKYlc+ADxwrFm0lWWkI87GSaslrakT FK27g8sta9/uoIKcfaURtGNYFqmqvbRc6wStU7WysXPeOToEQUZ89Gzh0g1ndyMSUd9y fcuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729517363; x=1730122163; h=content-transfer-encoding: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=pOIQy5ysT8d///wbhEAnPyitbzLm0NU4UMAQOTN7XLc=; b=DJT809c4IAhs0XGg5cvzz/dVHOI45HFA18cEli+NI795Tvykbz0UrkHdtAcKKCd9R3 y6Wmtwzv6VC+qSL8ajoIINLtRWIm/wZ62Kol4Xt7WQTS1+q1Sp3PEUwSYD69G8VqFG4v obhxrXk2qm8VQ1U6CJqvZW0jjiHESIfLlaK3z+1aaQHaK6MoknO2NoSW3T24pom5J9po y6a9Dv0PcNzW6I4/IUyDYJv7KnVWCiaQuym0uprsQyI4qCalmmyF9WMtWN421PavEbp7 mY2MLlJf+cEKWCSkn6bP2lG02j/vAj4bMmEtG6gpWTx2Hq7bcvK0m/qb2FVtD+BHjUvB dI9A== X-Gm-Message-State: AOJu0YxcWKwG1xxJsBtD3xooU2oi/C18ckew+bB8fJTsGVZd60u0d/IP HDvlQCxPfJK+L055VIOrJc6v1j4QoyJubpVsuP4u4RNyNoCeldQIZ/T2ckCnIssTVz3bqojQRul xg4Wx1KXeJpZSatt1zoJ2R3FNseQ0KfUSeVk= X-Google-Smtp-Source: AGHT+IF4CMhlIlikRrqSzNeIdg7KGvY6v5ok6YHbRunAz8MAJNnpQ2hoBG0RwsrhK8hmQ2lDDn2wyhnZ17obZMc7FnY= X-Received: by 2002:a05:620a:1710:b0:7a4:d685:caa9 with SMTP id af79cd13be357-7b157bdf5e8mr1286788385a.48.1729517363120; Mon, 21 Oct 2024 06:29:23 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 21 Oct 2024 15:29:12 +0200 Message-ID: Subject: Re: [PHP-DEV] [RFC] Change behaviour of array sort functions to return a copy of the sorted array To: PHP internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: tovilo.ilija@gmail.com (Ilija Tovilo) Hi Gina On Mon, Oct 21, 2024 at 3:21=E2=80=AFPM Gina P. Banyard = wrote: > > On Sunday, 20 October 2024 at 18:42, Gina P. Banyard = wrote: > > > https://wiki.php.net/rfc/array-sort-return-array > > For an example, I'm going to pull out my solution to day 1 of the 2022 ad= vents of code: > > https://github.com/Girgias/advent-of-code/blob/19283e1f5ef503c8a4478e58aa= a57ff2fb7164c7/2022/01/puzzle.php#L25 > > > However, if the sort functions would return a useful value instead of `tr= ue` I could chain it together completely as follows: > > $top3 =3D array_slice( > rsort( > array_map( > 'array_sum', > array_map( > fn($v) =3D> explode("\n", $v), > explode( > "\n\n", > $input > ) > ) > ) > ), > 0, > length: 3 > ); Note that your example would still warn after this RFC, which is likely enough to deter people from writing code like this. https://3v4l.org/mRuoK