order sets before serialization, fixes #3