3 ms·
> That might well be, but the default sort comparison function is not a demonstration of it. Yes it is. It demonstrates weak typing which I also think is broke
by rdtsc 13y ago
> That might well be, but the default sort comparison function is not a demonstration of it.
Yes it is. It demonstrates weak typing which I also think is broken. If I wanted to sort a string, I would have done this:
> ["1","2","3"].sort()
> (hell, getting the exact same behavior in Python could hardly be simpler: `ar.sort(key=str)`. There, I broke it.
You broke it by writing more code. That's good. Javascript is broken __unless__ you write additional code. That's the crux of the matter.
- masklinn 13y ago> Yes it is. It demonstrates weak typing which I also think is broken. For the third time, no. There is no implicit conversion process during the comparison, the default comparison is explicitly specified to convert both of its arguments to strings before doing the comparison. Javascript does not trigger conversions to compare two numbers, so relying on the type system would actually do exactly what you want. > You broke it by writing more code. Meanwhile you completely missed the point of posting the snippet. > Javascript is broken __unless__ you write additional code. And as I replied the first time around, I have no objection with the assertion that the default sort comparison function is garbage, I have an issue with your assertion that it is a consequence of weak typing because it is not.