Map keys should be sorted alphabetically as Rust expects
When an argument is or contains a Map Rust expects the keys to be alphabetically ordered but JS doesn't enforce that. This will cause unclear errors right now. Soroban client likely should perform a key sort behind the scenes in order to avoid this issue.
@willemneal is this something you can incorporate (or needs to be incorporated?) into ContractSpec? I can look into doing this in parallel for nativeToScVal.
Good question, I need to look at how the ContractSpec handle's maps, but I think it should be done there.
I'm not sure this is the responsibility of the contract spec.
The contract spec doesn't have an opinion on how the Map val is ordered. It presents the fields in the order of code such that they can be regenerated in the same order.
Also, Maps are used irrespective of a contract type, and so the JS lib and every SDK needs to be able to support sorting a maps entries so they're valid. Map keys may be numbers, symbols, strings, bytes, anything really. ~This is going to be pretty challenging.~