Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108844 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 94899 invoked from network); 4 Mar 2020 19:10:37 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 4 Mar 2020 19:10:37 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A8C15180548 for ; Wed, 4 Mar 2020 09:30:03 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS8075 40.64.0.0/10 X-Spam-Virus: No X-Envelope-From: Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12olkn2077.outbound.protection.outlook.com [40.92.21.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 4 Mar 2020 09:30:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lvU+Q1VkZjHTJiS1iWNdbPNZGbZLz8pEN5tkf71nWyhjmVb9U9x/RLtxvp+ckWMwnDO7wsT/vs47/pKW54vJhblr+P9LoRv3iq9gQZ6M0c+xcpbifmTr5KF9slpNrPjoWg4aYtSAwuKUGLbdsE6Vs1uAJZ8V6RVIoVK0NsNhVo7REzyNV5E7Sh8GNyOd+KV14acUSPjTdE33XcRucSUyotrQEZ4yIW7FUva/PCWO2ET4coJkSDZRGzFyx2b0Xfn1UuRebvgyEUXajQDbkifX+ndSL1xYz+YxSqGW43lGoRbLrrLhGBaUut0FuX8t5bhRGXTYZdB+107XlCi/SOVnkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QdLy4qHoDSqmPCk/PidFZ/NCx6hyb1/vT24fdEVLTqw=; b=NzGYRYih/YEQwbe09g98Bp51J1c0kG51VnwJdcTnpMaW66czGU5667dJ7Cj3RnIhdnwiZvZppQudFfN33SMg2AY4FPrrwb3awx2s/tU2W47NZdvlp2U/aVpcOuZ+Qiv6RkwiPH4eZcOb1h0JFZn392Ut1GLnGK1SBSre042lYssPkzBKHiWqo3YSoWZkrkIsk7s9DuSqmgaUBISxS0WVjHEJsizluUNDjqBoQ5oj9ZUj5l9CM10AJ9CA+FS5OBJHxvR6fmYcb1svSvyop9C9SNGnsltoYHuE9l3ccziNvDXhb0WugnU2WYWmMmLYZWKr+Jt0aEnqHnC6KMIwsneG1A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QdLy4qHoDSqmPCk/PidFZ/NCx6hyb1/vT24fdEVLTqw=; b=qVX80tlVhhVST96W4BEmEFbba7BWqvB3hJ8oDIS2e+guyQgQBVJHwZRlahTA/ZF4mvf4quePBTz/hIUbjTNe+GLbqpVme7iImjR+YXyqsI2yKIFq9H1Jb2QNGSQ90Y/e7LNgVWVr50bsAqQRZ07wYoudNVSRvPOuVko7TCqlv0sm+WQQ5hMNsjw3uXVIR6Oksr6mqPJBb0Mx+j1Gk6lcz8ZFaMTMChEz4DS5KmbndnD70m/cOcIruukWTjpUj4ZmE7WyY6pDaV/b5/qKiS9JzzXAEV8isqXT1LPbFea/hM8KPWjS4Ez1MFCkXrMU8+i4jmacLUgF6fpsC9N81ss8YA== Received: from MW2NAM12FT040.eop-nam12.prod.protection.outlook.com (2a01:111:e400:fc65::3c) by MW2NAM12HT070.eop-nam12.prod.protection.outlook.com (2a01:111:e400:fc65::202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2793.7; Wed, 4 Mar 2020 17:30:02 +0000 Received: from DM5PR07MB3067.namprd07.prod.outlook.com (2a01:111:e400:fc65::34) by MW2NAM12FT040.mail.protection.outlook.com (2a01:111:e400:fc65::228) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2793.5 via Frontend Transport; Wed, 4 Mar 2020 17:30:02 +0000 Received: from DM5PR07MB3067.namprd07.prod.outlook.com ([fe80::1133:bcac:caf1:d588]) by DM5PR07MB3067.namprd07.prod.outlook.com ([fe80::1133:bcac:caf1:d588%3]) with mapi id 15.20.2772.019; Wed, 4 Mar 2020 17:30:02 +0000 To: Nikita Popov , PHP internals Thread-Topic: [PHP-DEV] Make sorting stable Thread-Index: AQHV8kPunyeuXKV5iEqDcKcWxF+rfqg4riJC Date: Wed, 4 Mar 2020 17:30:01 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-CA, en-US Content-Language: en-CA X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:5ACC441A98794CF7991EA89A867714D0F7424205EF710C2CAD57B5D1306E0ACC;UpperCasedChecksum:C1C5BF616A7B10B3BF557C6F16099BF5459C73007E7FF9AEDA0A824027895EFA;SizeAsReceived:7106;Count:45 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [X+LJ4D1LY3qa9IsmNYk3YhpoPMsVO41pYOB9lqlDhksaB6yY/rjN3buY+t5P21zLHct2fkq0fEM=] x-ms-publictraffictype: Email x-incomingheadercount: 45 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: bbed2e30-123d-47b8-bb70-08d7c061aba4 x-ms-traffictypediagnostic: MW2NAM12HT070: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: kfGSFH++Qxpyq2M5M6yhsNWsY/lsQlVrlkXztz7dsGtHxkR78XWCMKMNnWQSR92yBaUISlLkqQ59JFq76HXbVHiWH4Am9sKnhclTpOIUjYr7ooSIqY1p/Ry841Y82xY6OIzvCrffoziTNqnNpJ69NtaPCYZfbNpWjFVgUcq/iIqkV7Ew/cj/UyS/TkGKEFcbMPbBxpBIQgjS70rwuEurdqHDF/XExiY5yDguBV0H8OM= x-ms-exchange-antispam-messagedata: 4NB21Yav66K00cQo8jwkrIS5aS3M9uV7SjrDJMcu3Bc1Fm0B4Ie8iacERS+AvywGH/sEvEv0rUxDx8dGuZNqFZ82xj4tWePiT8OzQJ2vuO1+T8Xs2Lax/P5Sxn8rj0lwWhVQYb7iFfw2qMm/SxxPplb8/+wIo2x/u8gYhdB3KfclqBxASP8Z/AAwbKX5/ehdHFgdCODBvaM7AfMeK0KFcA== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: bbed2e30-123d-47b8-bb70-08d7c061aba4 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Mar 2020 17:30:01.9205 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2NAM12HT070 Subject: Re: [PHP-DEV] Make sorting stable From: tysonandre775@hotmail.com (tyson andre) > What do people think about this? Is there interest in making sorting=0A= > stable? Is it okay to break code using illegal comparison callbacks?=0A= =0A= I'd be interested in having a stable sort.=0A= When migrating from php 5.6 to 7 a long time ago,=0A= the fact that sorting was no longer stable was an inconvenience for reasoni= ng about code=0A= (such as sorting a list of elements to render),=0A= and making it stable again would be a benefit for people reading php code= =0A= (e.g. JS implementations now guarantee it - https://v8.dev/features/stable-= sort).=0A= I used the same type of userland fallback you discussed.=0A= =0A= For illegal comparison callbacks, it would be useful to emit a notice such = as the following:=0A= (Not sure if the following would be accurate for all edge cases)=0A= =0A= "E_DEPRECATED: The callback for sort() should return an integer, but return= ed a boolean.=0A= To guarantee a correct sort, implementations should return negative numbers= =0A= if an element is less than another element.=0A= To preserve the incorrect sorting behavior, cast the returned result to an = integer."=0A= =0A= (and check if the error handler threw a Throwable)=0A= =0A= - Tyson=