This builds off of f951aa063f7, adding a weight parameter which can be
used to change the order of items when they have the same match score.
In the future, if string searching gets a C++ API, we could use an
optional parameter for the weight, since it is not used yet.
I tested this by adding it to D8286 temporarily in a simple situation.