Skip to content

Conversation

alexcjohnson
Copy link
Collaborator

Not the first time I've been bitten by the default sort being alphabetical even if the items are numbers... This made a bug where if you tried to add annotations 9 and 10 in a single relayout, it would try to add 10 first but it couldn't do that because 9 didn't exist yet (or if it did, 10 would get inserted in the array in the wrong places) and similar problems on deletion.

@etpinard OK?

}

var componentNums = Object.keys(edits).map(Number).sort(),
var componentNums = Object.keys(edits).map(Number).sort(function(a, b) { return a - b; }),
Copy link
Contributor

Choose a reason for hiding this comment

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

You might want to use Lib.sorterAsc to DRY it up 🌴

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ah thanks - should've guessed we'd have that already exposed somewhere!

.then(done);
});

it('should sort correctly when index>10', function(done) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nice test!

@etpinard
Copy link
Contributor

etpinard commented May 1, 2017

💃 after that little bit of 🌴

@etpinard
Copy link
Contributor

etpinard commented May 1, 2017

💃

@alexcjohnson alexcjohnson merged commit 2bac6ef into master May 1, 2017
@alexcjohnson alexcjohnson deleted the component-sort branch May 1, 2017 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants