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

Add sort-alternatives rule #235

Merged
merged 11 commits into from
Jun 9, 2021
Merged

Add sort-alternatives rule #235

merged 11 commits into from
Jun 9, 2021

Conversation

RunDevelopment
Copy link
Collaborator

This resolves #214.

This adds the sort-alternatives rule.

I constrained the rule to only sort alternatives containing certain characters and non-star quantifiers. We might want to change these constraints in the future but they seem to be a good balance right now.

The implementation will be able to handle any change in constraints. Even without any constraints, it will still work correctly (= it won't sort alternatives if it changes the pattern) but the sorting might not make much sense (e.g. it will sort lists of punctuation characters).

One important note: numbers get special treatments. List (and sublists) containing only numbers will be sorted by value and not lexicographically. E.g. 3|5|16|1|32 will be sorted as 1|3|5|16|32 and not 1|16|3|32|5.

@RunDevelopment RunDevelopment requested a review from ota-meshi June 8, 2021 15:02
Copy link
Owner

@ota-meshi ota-meshi left a comment

Choose a reason for hiding this comment

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

LGTM!

@ota-meshi ota-meshi merged commit 232ca08 into master Jun 9, 2021
@ota-meshi ota-meshi deleted the sort-alternatives branch June 9, 2021 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sort word lists rule
2 participants