Sort same ranked items alphabetically rather than by the index they were inputted.
Updated tests.
One new test.
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']
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!