DynamoDB is sorting sets automatically under the hood. In order to reproduce that behaviour, I am sorting values of that type. You can reproduce that behaviour easily when storing data in an actual DynamoDB.
Sort sets to mimic behaviour of DynamoDB
Amazon documentation says the Set data type is not sorted and it doesn't preserve the order of the values. I am not sure whether it is a good idea to depend on the undocumented behavior of Set data type.