def sort_matches(matches, basename)
        extname = File.extname(basename)
        aliases = @reverse_aliases[extname] || []

        matches.sort_by do |match|
          extnames = match.sub(basename, '').scan(/\.[^.]+/)
          extnames.inject(0) do |sum, ext|
            if i = extensions.index(ext)
              sum + i + 1
            elsif i = aliases.index(ext)
              sum + i + 11
            else
              sum
            end
          end
        end
      end
def sort_matches(matches, basename)
        extname = File.extname(basename)
        aliases = @reverse_aliases[extname] || []

        matches.sort_by do |match|
          extnames = match.sub(basename, '').scan(/\.[^.]+/)
          extnames.inject(0) do |sum, ext|
            if i = extensions.index(ext)
              sum + i + 1
            elsif i = aliases.index(ext)
              sum + i + 11
            else
              sum
            end
          end
        end
      end
Sorts candidate matches by their extension
 priority. Extensions in the front of the `extensions` carry
 more weight.