> What do people think about this? Is there interest in making sorting > stable? Is it okay to break code using illegal comparison callbacks?
I'd be interested in having a stable sort. When migrating from php 5.6 to 7 a long time ago, the fact that sorting was no longer stable was an inconvenience for reasoning about code (such as sorting a list of elements to render), and making it stable again would be a benefit for people reading php code (e.g. JS implementations now guarantee it - https://v8.dev/features/stable-sort). I used the same type of userland fallback you discussed. For illegal comparison callbacks, it would be useful to emit a notice such as the following: (Not sure if the following would be accurate for all edge cases) "E_DEPRECATED: The callback for sort() should return an integer, but returned a boolean. To guarantee a correct sort, implementations should return negative numbers if an element is less than another element. To preserve the incorrect sorting behavior, cast the returned result to an integer." (and check if the error handler threw a Throwable) - Tyson -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php