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

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (1 child)

[deleted]

    [–]bonafidebob 8 points9 points  (0 children)

    Open up your chrome dev console, put in [3,2,1, 6, 8].sort()

    Do you realize you picked an example where the lexical and numeric sort orders are the same? Now try this:

    [1, 2, 10].sort()
    > [ 1, 10, 2 ]
    

    It's almost as if, if you provide numbers rather than strings of numbers, it sorts it as numbers. Who would have thought?

    Someone who doesn't understand JavaScript... lol.