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

Do deep sort instead of shallow sort. Allow sort.js to be run without… #12

Merged
merged 2 commits into from
Nov 28, 2019

Conversation

michal-huzevka
Copy link
Contributor

… any arguments

sort.js Outdated
// E.g. reordering questions-api.json's characterMapCharacters would
// cause the special characters to appear in a different order in
// the product.
if (val && !Array.isArray(val) && typeof val === 'object') {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you need the !Array.isArray(val) here? Or are arrays objects in JS? If so, I'd swap the Array.isArray and the typeof

Copy link
Contributor

Choose a reason for hiding this comment

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

@shtrom welcome to typeof confusion land :)
image

http://web.mit.edu/jwalden/www/isArray.html

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, arrays are considered objects in JS. I'll swap the two then.

Copy link
Contributor

@shtrom shtrom left a comment

Choose a reason for hiding this comment

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

Looks good to me, but I would prefer if the data changes were in a separate commit to the code change.

@michal-huzevka michal-huzevka merged commit 1ccf328 into master Nov 28, 2019
@michal-huzevka michal-huzevka deleted the improve-sort-labels branch November 28, 2019 02:56
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.

3 participants