I'd like to return 1 for 'Mikhaïlovitch', because 'm' and 'M' are "alike", and "i" and "ï" are "alike" as well. That way, the string 'mikailovitch' is closer to 'Mikhaïlovitch' than to 'Vikhaklovitch'.
So I made one simple change. I added a variable in the closure
var collator = Intl.Collator("generic", { sensitivity: "base" });
And I changed the condition for "substitution", from
I like our library, but I wanted to be more lenient on case and/or accent differences in the input.
For example, with your library:
I'd like to return 1 for 'Mikhaïlovitch', because 'm' and 'M' are "alike", and "i" and "ï" are "alike" as well. That way, the string 'mikailovitch' is closer to 'Mikhaïlovitch' than to 'Vikhaklovitch'.
So I made one simple change. I added a variable in the closure
And I changed the condition for "substitution", from
to
With this simple change, I got much better results on accented letters and difference in case.