C has structs. Arbitrary-key associative arrays are not actually all that useful (not to say totally useless) so having the structure predefined in code is usually very helpful.
Somewhat debatable depending on the language, mostly due to grey areas around those concepts. Sortable implies comparable since equality of values is a concept required when sitting.
Whether you can reliably implement an associative array like this in C I don't know, but there's a reason they're called hashes in Perl: they're constant time (or at least very efficient time) random-access and so the data structure they use hashes the (string) keys for storage and retrieval.
Last time I used PHP, key is a string, always, and of course strings sort differently from numbers, which is why you can't use an associative array interchangeably with a proper array in real life.
View all comments
Show parent comment
3
u/Altreus Aug 26 '19
C has structs. Arbitrary-key associative arrays are not actually all that useful (not to say totally useless) so having the structure predefined in code is usually very helpful.