Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order fields alphabetically in serialization #229

Open
wyfo opened this issue Oct 26, 2021 · 1 comment
Open

Order fields alphabetically in serialization #229

wyfo opened this issue Oct 26, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@wyfo
Copy link
Owner

wyfo commented Oct 26, 2021

See #226 (reply in thread) (a workaround is given).

Such ordering should be handled by order decorator.

My first idea is to pass a function parameter to order, which would be applied to the list of aliases and return them ordered. Alphabetical ordering would then just be @order(sorted)

However, it would maybe not be very intuitive that the function operates on aliases while only field names are allowed in the list arguments.
Should this restriction be released before? IMO this is find.

By the way, dynamic ordering should be settable globally through a settings key. (maybe settings.serialization?)

@wyfo wyfo added the enhancement New feature or request label Oct 26, 2021
@CaptainDriftwood
Copy link

CaptainDriftwood commented Oct 27, 2021

I think it would be awesome to be able to pass in a function to order, however would resolving against the aliased field names be the optimal approach? I think it would be best to be consistent with either taking a list of aliased field names (since the aliased fields names is what the function that would be passed in would be operating against), or having the passed in function operate against the field names instead of the aliases.

Also, what if instead of using the field names as the value to sort against, what if one wanted to use the field values instead when performing any kind of ordering? Could that be possible, and if so, what would that look like?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants