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

Support natural sorting on attributes #356

Merged
merged 16 commits into from
Oct 6, 2023
Merged

Support natural sorting on attributes #356

merged 16 commits into from
Oct 6, 2023

Conversation

JasperCraeghs
Copy link
Member

@JasperCraeghs JasperCraeghs commented Sep 25, 2023

Closes #354

The option :sort: of the item-attributes-matrix sorts items on attribute values alphabetically. This is good and desired as the default behavior.

A use case for natural sorting on attribute values came up. For example, sorting on values of the attribute effort like 11d and 5d.

This PR adds a new configuration value traceability_attributes_sort = {"effort": natsort.natsorted}. Any item-attributes-matrix that contains the effort attribute will sort on attribute values naturally.
This default value can be overridden in conf.py like all other configuration values.

@JasperCraeghs JasperCraeghs changed the title Sort naturally instead of alphabetically on attributes Support natural sorting on attributes Sep 25, 2023
@JasperCraeghs JasperCraeghs marked this pull request as draft September 25, 2023 12:59
@JasperCraeghs JasperCraeghs requested a review from Letme September 25, 2023 16:25
Copy link

@pietvr pietvr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

natsort introduced on effort

@JasperCraeghs JasperCraeghs marked this pull request as ready for review September 27, 2023 11:32
@JasperCraeghs
Copy link
Member Author

JasperCraeghs commented Oct 5, 2023

There are other sorting methods besides alphabetical and natural. The configuration must be flexible enough to support those as well. https://natsort.readthedocs.io/en/master/api.html#natsort-api

traceability_attributes_natsort = {"effort"}
becomes
traceability_attributes_sort = {"effort": natsort.natsorted}

@pietvr pietvr self-requested a review October 5, 2023 09:47
@JasperCraeghs
Copy link
Member Author

Is the additional cyclomatic complexity acceptable? Reducing it by creating a separate function wouldn't be beneficial in my opinion. @Letme

@Letme Letme merged commit 7706ed2 into master Oct 6, 2023
@Letme Letme deleted the natsort branch October 6, 2023 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sorting on efforts does not work
3 participants