JavaScript always know my truest of desires

kuneho@lemmy.world to Programmer Humor@programming.dev – 428 points –

38

You are viewing a single comment

Ugh, I just ran into this in Terraform. Why is this a thing?

It's just sorted alphabetically (technically it is the UTF16 code order). To be fair it's a sane default for most use cases. In JS case you can define a very simple callback to change the behavior to numeric sorting (a,b => a<b). Many other sorters provide a flag instead, but numeric sorting is seldom the default as it is not as useful most of the time in weakly typed languages.

weakly typed languages

Well, looks like we found the problem right there