Sort same ranked items alphabetically #64
Merged
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.
What:
Why:
Currently, if items are the same rank with the same key based index, the items are sorted based on their index in the starting input. This is fine in general but I believe it makes more sense to sort them alphabetically when they have the same ranking and also by length allowing the smaller words to float to the top and make filtering a progressive act.
Example:
search:
'ap'
input:
['wrapped','snap', 'pap']
old output:
['wrapped','snap', 'pap']
new output:
['pap', 'snap', 'wrapped']
How:
We can take advantage of the base String.prototype.localeCompare() to do a comparison while still accepting diacritics.
Checklist:
Comments
This may need discussion and you may not like the approach or the idea at all, just let me know or if you find any issues.
Thanks!