code: function sortMatches(self, matches, basename) {
    var weights  = {};
  
    var ext_name = path.extname(basename);
    var aliases  = has(self.__aliases__, ext_name) ? self.__aliases__[ext_name] : [];
  
  
    matches.forEach(function(match) {
      // XXX: this doesn't work well with aliases
      //      i.e. entry=index.php, extnames=index.html
      var extnames = match.replace(basename, '').split('.');
  
      weights[match] = extnames.reduce(function(sum, ext) {
        if (!ext) {
          return sum;
        }
  
        ext = '.' + ext;
  
        if (self.__extensions__.indexOf(ext) >= 0) {
          return sum + self.__extensions__.indexOf(ext) + 1;
        }
  
        if (aliases.indexOf(ext) >= 0) {
          return sum + aliases.indexOf(ext) + 11;
        }
  
        return sum;
      }, 0);
    });
  
    return matches.sort(function(a, b) {
      return weights[a] > weights[b] ? 1 : -1;
    });
  }
docs: Sorts candidate matches by their extension priority. Extensions in the front of the `extensions` carry more weight.