Sort by size and alphabet, so the first match can be returned immediately
555316
static Rule[] getOrderedRules(final Rule[] rules) {

        final Comparator<Rule> c = Comparator.comparing(Rule::getSize).reversed().thenComparing(Rule::getPattern);

        final Rule[] result = Arrays.copyOf(rules, rules.length);
        parallelSort(result, c);
        return result;
    }
890801
private static String firstCharToLowerCase(String word) {
		if (word.length() == 1) {
			return word.toLowerCase();
		}
		char c = word.charAt(0);
		char newChar;
		if (c >= 'A' && c <= 'Z') {
			newChar = (char) (c + 32);
		}
		else {
			newChar = c;
		}
		return newChar + word.substring(1);
	}
866591
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
588364
function sortBy(array, attr) {
  assert(Array.isArray(array));
  return array.sort(function(a,b) {
    a = a[attr];
    b = b[attr];
    return (a < b) ? -1 : ((a > b) ? 1 : 0);
  });
}
990868
function sortObjName(a, b) {
  let lenA = a.length
  let lenB = b.length
  let len = lenA > lenB ? lenB : lenA

  for (let i = 0; i < len; i++) {
    let codeA = a.charCodeAt(i)
    let codeB = b.charCodeAt(i)
    let cmpResult = cmpCode(codeA, codeB)

    if (cmpResult !== 0) return cmpResult
  }

  if (lenA > lenB) return 1
  if (lenA < lenB) return -1

  return 0
}
1270400
def _build_matches(matches, uuids, no_filtered, fastmode=False):
    """"""

    result = []

    for m in matches:
        mk = m[0].uuid if not fastmode else m[0]
        subset = [uuids[mk]]

        for id_ in m[1:]:
            uk = id_.uuid if not fastmode else id_
            u = uuids[uk]

            if u not in subset:
                subset.append(u)

        result.append(subset)

    result += no_filtered
    result.sort(key=len, reverse=True)

    sresult = []
    for r in result:
        r.sort(key=lambda id_: id_.uuid)
        sresult.append(r)

    return sresult
1360048
def _sort(self, a, b):
        '''
        
        '''
        ret = 0

        # first we check q, higher values win:
        if a[1] != b[1]:
            ret = cmp(a[1], b[1])
        else:
            found = False
            for i in range(2):
                ai = a[0][i]
                bi = b[0][i]
                if ai == '*':
                    if bi != '*':
                        ret = -1
                        found = True
                        break
                    else:
                        # both *, more verbose params win
                        ret = cmp(len(a[2]), len(b[2]))
                        found = True
                        break
                elif bi == '*':
                    ret = 1
                    found = True
                    break

            if not found:
                ret = cmp(len(a[2]), len(b[2]))

        return ret
218625
private int findFirst(CharSequence input, int beginIndex, int rewindIndex) {
        int first = -1;
        boolean atomBoundary = true;
        for (int i = beginIndex; i >= rewindIndex; i--) {
            char c = input.charAt(i);
            if (localAtomAllowed(c)) {
                first = i;
                atomBoundary = false;
            } else if (c == '.') {
                if (atomBoundary) {
                    break;
                }
                atomBoundary = true;
            } else {
                break;
            }
        }
        return first;
    }
793660
def _sorted_nicely(self, l):
        
        convert = lambda text: int(text) if text.isdigit() else text
        alphanum_key = lambda key: [ convert(c) for c in re.split('([0-9]+)', key) ]
        return sorted(l, key = alphanum_key)
80900
def sort(self, key, *get_patterns,
             by=None, offset=None, count=None,
             asc=None, alpha=False, store=None):
        """"""
        args = []
        if by is not None:
            args += [b'BY', by]
        if offset is not None and count is not None:
            args += [b'LIMIT', offset, count]
        if get_patterns:
            args += sum(([b'GET', pattern] for pattern in get_patterns), [])
        if asc is not None:
            args += [asc is True and b'ASC' or b'DESC']
        if alpha:
            args += [b'ALPHA']
        if store is not None:
            args += [b'STORE', store]
        return self.execute(b'SORT', key, *args)
1347691
def humansort(l):
    
    import re

    def alphanum_key(s):
        # Turn a string into a list of string and number chunks.
        # e.g. "z23a" -> ["z", 23, "a"]
        def tryint(s):
            if s.isdigit():
                return int(s)
            return s

        return [tryint(c) for c in re.split("([0-9]+)", s)]

    l.sort(key=alphanum_key)
    return None
1184001
def underscore_search(input, list, first_match=false)
      meth = first_match ? :find : :select
      return (first_match ? input : [input]) if list.include?(input)
      input = input.to_s
      if input.include?("_")
        underscore_regex = input.split('_').map {|e|
          Regexp.escape(e) }.join("([^_]+)?_")
        list.send(meth) {|e| e.to_s =~ /^#{underscore_regex}/ }
      else
        escaped_input = Regexp.escape(input)
        list.send(meth) {|e| e.to_s =~ /^#{escaped_input}/ }
      end
    end
203527
function startsWith (haystack, needle, startPosition) {
    startPosition = startPosition || 0;
    return haystack.lastIndexOf(needle, startPosition) === startPosition;
  }
936849
def match(self, selector, index):
        """"""

        pseudo = None
        m = self.re_pseudo_name.match(selector, index)
        if m:
            name = util.lower(css_unescape(m.group('name')))
            pattern = self.patterns.get(name)
            if pattern:
                pseudo = pattern.match(selector, index)
                if pseudo:
                    self.matched_name = pattern

        return pseudo
1362660
def p_startswith(self, st, ignorecase=False):
        ""
        length = len(st)
        matcher = result = self.input[self.pos:self.pos + length]
        if ignorecase:
            matcher = result.lower()
            st = st.lower()
        if matcher == st:
            self.pos += length
            return result
        return False
213752
def sort_item(iterable, number, reverse=False):
    """"""
    return sorted(iterable, key=itemgetter(number), reverse=reverse)
155667
def chars_after(chars, match):
    
    if match.end >= len(match.input_string):
        return True
    return match.input_string[match.end] in chars