Kantis / ks3

KotlinX Serialization Standard Serializers (KS3)
Apache License 2.0
20 stars 4 forks source link

Serializers to sort collections #112

Closed sschuberth closed 9 months ago

sschuberth commented 9 months ago

In serialized formats, it's often nice for a better overview to have collection entries sorted naturally / alphabetically / by some comparator. So what do you guys think about adding convenience serializers to do that?

Kantis commented 9 months ago

I'm not sure if it would be more convenient than simply sorting your data before serializing. I guess for bigger structures it could be?

How do you propose it would work?

sschuberth commented 9 months ago

I guess for bigger structures it could be?

Yes, and for immutable data class hierarchies you don't want to create copies just to sort a deeply nested collection for serialization. In memory, the order does not matter. This is just for readability and canonization in the serialized format.

How do you propose it would work?

Similar to these, but more generically implemented.

Kantis commented 9 months ago

Okay, sure! Would you like to contribute it?

sschuberth commented 9 months ago

Maybe, yes, eventually 😀 I doesn't have high priority for me currently, though.