diff --git a/jamcodec/types.py b/jamcodec/types.py index 7f6f78d..768a04a 100644 --- a/jamcodec/types.py +++ b/jamcodec/types.py @@ -959,8 +959,11 @@ def __init__(self, key_def: JamCodecTypeDef, value_def: JamCodecTypeDef): def encode(self, value: Union[typing.Mapping, list]) -> JamBytes: if isinstance(value, Mapping): - # Sort Map by keys - value = sorted(value.items(), key=lambda x: x[0]) + value = value.items() + + if type(value) is list: + # Sort by first item + value = sorted(value, key=lambda x: x[0]) # Encode length of Vec data = VarInt64.encode(len(value))