4 ms·
Pretty sure I’ve actually tripped on sort() myself before by assuming it was a new array. It does make sense for performance though, creating a new array would
by dahart 5y ago
Pretty sure I’ve actually tripped on sort() myself before by assuming it was a new array. It does make sense for performance though, creating a new array would be a bad default choice for performance, for the same reasons that forEach is generally faster than map all else being equal.
- gmac 5y agoTrue. I like Ruby's solution with exclamation marks, such as `sort!`, to make this kind of behaviour obvious.