• 3 Posts
  • 157 Comments
Joined 1 year ago
cake
Cake day: July 10th, 2023

help-circle






  • JavaScript is what’s called an “untyped” language, so here, it assumes that the numbers are words, and tries to sort them alphabetically. Specifically, it tries to sort them alphabetically as a dictionary would in a left-to-right language like English. In this case, just as “apple” would come before “asterisk”, 100000 would come before 21.

    (Some would argue that it’s more of a “weakly typed” language, I know, but I’m trying not to be pedantic here.)

    Sorting them as actual numbers would require some extra explicit instructions and guides. Most typed languages, like C, aren’t like this.