Make prefLabel policies deterministic by using label string sort order to break ties #91
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In issue #81, @kouralex pointed out that prefLabel selection policies are not deterministic in cases where there are ties - for example if two candidate labels have the same length when using the
shortest
policy. The proposed solution, implemented in #82, was to introduce locale-aware alphanumeric sorting as a separate policy. But there are problems in the approach of that PR because locale-aware sorting is a bit difficult to implement well.This PR has narrower scope and only tries to fix the issue of nondeterministic selection. The simple fix is just to use the label itself (its string value) as the final key for sorting, when other policies such as
shortest
orlongest
cannot produce a single unambiguous result. The "winning" label may not be any better than the other candidates, but at least it's the same every time.