DEV Community

[Comment from a deleted post]
Collapse
 
lexlohr profile image
Alex Lohr

No. Programming languages should just do what they're specified to do.

You can't expect a front end language to behave exactly like a system programming language, because it has a completely different set of requirements. But just for example, would you expect a language to use the concept of borrowing for memory management? Rust does a pretty good job doing so, but it is largely unexpected. Let me emphasize again: please don't blame a language for your expectations.

That being said, yes, it might be confusing that Array.prototype.sort is expecting a function to behave well around numbers, but at least it is specified behavior and thus difficult to change. One could attempt to make a proposal to add Array.valueSort(), which is using toValue() instead of toString() for the comparison. Feel free to contact TC39, who is maintaining the official specifications.