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

Sort actions and senses alphabetically #194

Merged
merged 4 commits into from
Jun 6, 2018

Conversation

djohalo2
Copy link
Contributor

@djohalo2 djohalo2 commented Jun 3, 2018

Fixes #189

@codecov-io
Copy link

codecov-io commented Jun 3, 2018

Codecov Report

Merging #194 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update daaafc5...0012959. Read the comment docs.

Copy link
Owner

@olistic olistic left a 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);
Copy link
Owner

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?

Copy link
Contributor Author

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!

Copy link
Owner

Choose a reason for hiding this comment

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

Good, thanks @djohalo2!

Copy link
Owner

@olistic olistic left a 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);
Copy link
Owner

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);

@djohalo2
Copy link
Contributor Author

djohalo2 commented Jun 6, 2018

No problem, this looks better!

Copy link
Owner

@olistic olistic left a comment

Choose a reason for hiding this comment

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

Thanks @djohalo2!

@olistic olistic merged commit e29bf8d into olistic:master Jun 6, 2018
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.

None yet

3 participants