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

Use a stable sort in Patch.applyAll #126

Merged
merged 1 commit into from Nov 5, 2019
Merged

Use a stable sort in Patch.applyAll #126

merged 1 commit into from Nov 5, 2019

Conversation

jathak
Copy link
Member

@jathak jathak commented Nov 5, 2019

Patches can be order-dependent when insertion patches are involved, so
we need to use a stable sort in Patch.applyAll.

@jathak jathak requested a review from nex3 November 5, 2019 01:01
var sortedPatches = patches.toList()
..sort((a, b) => a.selection.compareTo(b.selection));
var sortedPatches = patches.toList();
mergeSort(sortedPatches,
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a comment here explaining why you're using mergeSort() over List.sort().

..sort((a, b) => a.selection.compareTo(b.selection));
var sortedPatches = patches.toList();
mergeSort(sortedPatches,
compare: (a, b) => a.selection.compareTo(b.selection));
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think you need to pass this, I think calling compareTo() is the default behavior.

Patches can be order-dependent when insertion patches are involved, so
we need to use a stable sort in Patch.applyAll.
@jathak jathak merged commit 0e1d6ab into master Nov 5, 2019
@jathak jathak deleted the stable-sort branch November 5, 2019 17:06
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

2 participants