4 ms·
> I'm not sure it's unexpected. What do YOU expect when you ask someone to sort items that are clearly numbers? I don't know about you, but I do not expect wh
by naikrovek 6y ago
> I'm not sure it's unexpected.
What do YOU expect when you ask someone to sort items that are clearly numbers?
I don't know about you, but I do not expect what actually happened.
- danShumway 6y agoWe don't know that the items are clearly numbers, arrays in Javascript are untyped. Your proposal is that Javascript's default sort algorithm should change behaviors based on whether it can do an extra O(n) loop over the entire array and check whether `typeof x === 'number'` evaluates to true for each index? I don't think that's a good idea.