Repository navigation
Add compare argument for array.sorted - #5371
bluebear94 wants to merge 2 commits into
Conversation
|
catch_unwind also doesn't work on wasm, so it's kind of a non-starter :/ |
|
How shall we proceed here? |
|
Honestly, I’m not sure and that’s why it’s taken a long time for me to comment back. I think this addition isn’t worth the possible downsides, at least until we get more info on how limiting the current |
|
In cases where a comparison function is provided, maybe we could simply implement our own sorting algorithm? After all, the cost of calling the function probably outweighs the time it takes to sort the array, even if we do not do it with an algorithm as optimized as the one used by Rust. |
|
I guess we could do that. |
cd12115 to
059c741
Compare
|
@bluebear94 I'd be on board with having a simple custom sorting implementation for that case. If you want to implement that, feel free to. Otherwise, I think we can close the PR. |
Fixes #5365.
I used
comparefor the argument name instead ofbybecausebycould plausibly refer to either the key or the comparison function.According to the Rust standard library documentation, sorting might panic when a non-total ordering function is provided. I’ve been unable to produce a panic so far, but I think this is an important issue to resolve. We could
catch_unwindsuch a panic, but this doesn’t solve the problem whenpanic=abortis turned on.