jQuery-Autocomplete
jQuery-Autocomplete copied to clipboard
Hoist exact matches to top of autocomplete suggestions
For query "Bee", with data:
var suggestions = [{
"value": "beetle"
},{
"value": "beezlebub"
},{
"value": "bee"
},{
"value": "beet"
}]
Used to suggest:
beetle
beezlebub
bee
beet
now suggests:
bee
beetle
beezlebub
beet
Could be improved further but it's better than no sorting.
Would actually be better to allow people to supply their own sort function, with something like this as the default, imho.
You can actually provide your own lookup function where you can filter and sort results anyway you want.
Also it would make sense that sort function can be provided via options and optional.