Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110143 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 86901 invoked from network); 12 May 2020 15:42:28 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 12 May 2020 15:42:28 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 237BF1804D3 for ; Tue, 12 May 2020 07:19:11 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 12 May 2020 07:19:10 -0700 (PDT) Received: by mail-lj1-f178.google.com with SMTP id u15so13866870ljd.3 for ; Tue, 12 May 2020 07:19:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=4V7t5MbhCnhkDJ25jEM4KSU0u5tMEvqyDkXp78RWmJ4=; b=PpYJ/FZqJHGbKaV7DseFl+Ag/LShwiIJ4Zjyx2+rISzyQ4V9Da2rYz5wXVyYuwf6Yt IEj3kKWFoAaewbbN0+EpauOhvUu7ZKlmF2ZxOQIpEV8yLdnhtlG29YoTF0LYlhzHf9SQ hNF8l+IIWOt7RitXe2ToeDlGnzWEWLa2Pj1F595IwWJQMt2PepSei448lfnSEnB2X8rs AL9ZFG3lcjNT7mNL4xBVqVpWv9pXBn457Dm5xTN6vX0I2qiOCD0574hnUYopii2UZsOQ FK+FhLHcdbxJcqPOBWvDDj+Wv/ZK01710bfusM1FsqjOYYU0OwCfgzgSxybepgpN7IJ1 tXRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=4V7t5MbhCnhkDJ25jEM4KSU0u5tMEvqyDkXp78RWmJ4=; b=Z8D9ZcQaPQQrxyJ/Y690sHm07biO0sTphaPxF7YY7lGTSDxYDTLxpMkJNu4nIPL7/7 gvldqvRsMH/y2XtTIJTyZJNVj+yr0BczTlwnl0A4slR8b/Umc+OIwvlNW+/rdcyizOkM l8KVOe2+m42TlYnHql5vrCgHXJYkm1/qBAdDEvVAU79xg+CwMQvdR1z4tTgQT/f3N46Z 5B0yJmnj0YrSiq6N3O9BKUiRDLlRzUGUsNpfJvqjG7u2iJlmfMAOdDns54mawtM2mLtg Aq+yZSq/dXMWB82NIJhhoWvMzu5RMOB2fnCNEPwfcBr2TAYz5Pnjymx0b2V0hYmd3P5e mUyA== X-Gm-Message-State: AOAM5302kaVi4/gcn0nLLruy9B/FOvcnPBloeVTVw1aPqKqtx65Xh9w4 MaVeuCTjrI9n0eE+oZet1ZSQ0zuXPq0oaQyutWaKPsIgVYE= X-Google-Smtp-Source: ABdhPJyEcZcnNANTzO7owV4YdvJNwBKVOgaOySLzRbykNpdt86xBSDPxyhrrbYlYL+C1wOsi7RpdflxmSoxIbyltw24= X-Received: by 2002:a2e:8884:: with SMTP id k4mr14310981lji.267.1589293143619; Tue, 12 May 2020 07:19:03 -0700 (PDT) MIME-Version: 1.0 Date: Tue, 12 May 2020 16:18:47 +0200 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary="00000000000044fe1205a57425a2" Subject: [RFC] Make sorting stable From: nikita.ppv@gmail.com (Nikita Popov) --00000000000044fe1205a57425a2 Content-Type: text/plain; charset="UTF-8" Hi internals, This was previously discussed in https://externals.io/message/108841, but I figured it would make sense to create an RFC for this change: https://wiki.php.net/rfc/stable_sorting As before, the implementation approach is to stick with the existing qsort and use a fallback comparison criterion, which is cheap to implement internally. The obvious alternative is to use a stable base sort like Timsort. I gave this a quick try in https://github.com/php/php-src/pull/5559, and it does better in some cases (already sorted data) and worse in others (random data). I don't plan to pursue this direction personally. (It may also be interesting to use pdqsort as the unstable base, which should make the "already sorted" case faster.) Regards, Nikita --00000000000044fe1205a57425a2--