* order alphabetically to get more predictable matching (when no matching is possible anymore)
This commit is contained in:
parent
3bf8545bfc
commit
9c8e720f2a
|
@ -2,10 +2,13 @@
|
|||
package net.sourceforge.filebot.similarity;
|
||||
|
||||
|
||||
import static java.util.Collections.*;
|
||||
|
||||
import java.util.AbstractList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Iterator;
|
||||
|
@ -92,7 +95,16 @@ public class Matcher<V, C> {
|
|||
if (level >= metrics.length || possibleMatches.isEmpty()) {
|
||||
// add the first possible match if non-strict, otherwise ignore ambiguous matches
|
||||
if (!strict) {
|
||||
disjointMatchCollection.addAll(possibleMatches);
|
||||
// order alphabetically to get more predictable matching (when no matching is possible anymore)
|
||||
List<Match<V, C>> rest = new ArrayList<Match<V, C>>(possibleMatches);
|
||||
sort(rest, new Comparator<Match<V, C>>() {
|
||||
|
||||
@Override
|
||||
public int compare(Match<V, C> o1, Match<V, C> o2) {
|
||||
return o1.toString().compareToIgnoreCase(o2.toString());
|
||||
}
|
||||
});
|
||||
disjointMatchCollection.addAll(rest);
|
||||
}
|
||||
|
||||
// no further refinement possible
|
||||
|
|
Loading…
Reference in New Issue