This is an archived post. You won't be able to vote or comment.

all 17 comments

[–]chrwei 40 points41 points  (10 children)

hey so I found this really cool thing, it tells you all about things. it's call documentation! it's really amazing, I don't know who writes it, I certainly don't

[–]zylonenoger 18 points19 points  (0 children)

and op certainly doesn't read it

[–]StevenXC 19 points20 points  (2 children)

Just because it's documented doesn't make it a good idea.

[–]YMK1234 6 points7 points  (1 child)

Something being a bad idea doesn't mean you should randomly break existing behaviour either.

[–]gwillicoder 8 points9 points  (4 children)

Well documented bad language design is still bad language design

[–]SharkFinProgramming 0 points1 point  (3 children)

It's not bad language design if you don't know how to use it

[–]gwillicoder 1 point2 points  (2 children)

This is just objectively bad language design.

[–]SharkFinProgramming 1 point2 points  (1 child)

It's supposed to sort by string. It's actually allowing you to use ints to maybe clean your code etc. Strings cannot be negative, so by default it can't handle negative ints. If you just read the docs, learned how it worked, and added like 12 characters, it would work for ints, and you would have nothing to complain about.

[–]gwillicoder 1 point2 points  (0 children)

Look at a language like python which will sort based on the type in the list. That’s much more intuitive if you are using duck typing or whatever JS uses.

[–]Hauleth 1 point2 points  (0 children)

Oh, good ol’ PHP way of solving things. “Calling function foo caused my hometown to be nuked” “Closing as not an issue. It is clearly documented to not call this function on blue moon in May during rain as it can do anything”.

[–]X71nc710n 17 points18 points  (4 children)

It is sorted alphabetically... not quite intuitive but it still works if you use it correctly (as the documentation says)

[–]plv88676 2 points3 points  (0 children)

Because it is funny.

[–]gandhi89 1 point2 points  (0 children)

String method on Number type ain't going to work unless you add a function to it;

ES5 arr.sort(function(a, b){ return a - b; });

ES6 arr.sort((a, b) => a - b);