-
Notifications
You must be signed in to change notification settings - Fork 487
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
Sort actions and senses alphabetically #194
Sort actions and senses alphabetically #194
Conversation
Codecov Report
@@ Coverage Diff @@
## master #194 +/- ##
=======================================
Coverage 92.29% 92.29%
=======================================
Files 86 86
Lines 1077 1077
Branches 180 180
=======================================
Hits 994 994
Misses 68 68
Partials 15 15 Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @djohalo2! Thanks for the changes, I made a small suggestion.
const actions = abilities.filter(ability => ability.action); | ||
const senses = abilities.filter(ability => !ability.action); | ||
const actions = abilities.filter(ability => ability.action).sort((a, b) => a.name > b.name); | ||
const senses = abilities.filter(ability => !ability.action).sort((a, b) => a.name > b.name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you refactor this, extracting the sort call and saving the result in a new variable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@olistic Sounds good, I was already thinking it might be better to do this just once, will pick this up today/tomorrow!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good, thanks @djohalo2!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commented, apologies for not having been clearer the first time!
@@ -1,17 +1,20 @@ | |||
<%_ | |||
const actions = abilities.filter(ability => ability.action); | |||
const senses = abilities.filter(ability => !ability.action); | |||
|
|||
const sortedActions = actions.sort((a, b) => a.name > b.name); | |||
const sortedSenses = senses.sort((a, b) => a.name > b.name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @djohalo2, what I originally meant is that you can sort the entire array of abilities just once, and then filter it. The resulting code is much simpler:
const sortedAbilities = abilities.sort((a, b) => a.name > b.name);
const actions = sortedAbilities.filter(ability => ability.action);
const senses = sortedAbilities.filter(ability => !ability.action);
No problem, this looks better! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @djohalo2!
Fixes #189