Open yantakus opened 9 years ago
Is there a way to sort results by relevance.
For example, if or options list is ['Canada', 'Abacan', 'Bolcan']. I type "Can" and see:
['Canada', 'Abacan', 'Bolcan']
Abacan Bolcan Canada
But "Canada" is the most relevant result, because it starts with our inputValue.
I have a sort function to handle it:
arr.sort((a, b) => { if (a.indexOf(inputValue) > b.indexOf(inputValue)) return 1; else if (a.indexOf(inputValue) < b.indexOf(inputValue)) return -1; else return 0; })
How can I implement it?
:+1:
Is there a way to sort results by relevance.
For example, if or options list is
['Canada', 'Abacan', 'Bolcan']
. I type "Can" and see:But "Canada" is the most relevant result, because it starts with our inputValue.
I have a sort function to handle it:
How can I implement it?