demo/typescript.js
function patternMatchCompareTo(match1, match2) {
        return compareType(match1, match2) ||
            compareCamelCase(match1, match2) ||
            compareCase(match1, match2) ||
            comparePunctuation(match1, match2);
    }
function patternMatchCompareTo(match1, match2) {
        return compareType(match1, match2) ||
            compareCamelCase(match1, match2) ||
            compareCase(match1, match2) ||
            comparePunctuation(match1, match2);
    }
Helper function to compare two matches to determine which is better.  Matches are first ordered by kind (so all prefix matches always beat all substring matches).  Then, if the match is a camel case match, the relative weights of the match are used to determine which is better (with a greater weight being better).  Then if the match is of the same type, then a case sensitive match is considered better than an insensitive one.