Key for sorting PEP8 results.

    Global fixes should be done first. This is important for things like
    indentation.
12864
def _priority_key(pep8_result):
    
    priority = [
        # Fix multiline colon-based before semicolon based.
        'e701',
        # Break multiline statements early.
        'e702',
        # Things that make lines longer.
        'e225', 'e231',
        # Remove extraneous whitespace before breaking lines.
        'e201',
        # Shorten whitespace in comment before resorting to wrapping.
        'e262'
    ]
    middle_index = 10000
    lowest_priority = [
        # We need to shorten lines last since the logical fixer can get in a
        # loop, which causes us to exit early.
        'e501'
    ]
    key = pep8_result['id'].lower()
    try:
        return priority.index(key)
    except ValueError:
        try:
            return middle_index + lowest_priority.index(key) + 1
        except ValueError:
            return middle_index
221524
def _getSortedString(o):
	
	# todo: replace this with something like pprint on Python upgrade
	# We assume here that any container type is either list or tuple which may not always hold
	if isinstance(o, (dict)):
		pkeys = sorted(o.keys(), key=_lowercaseToStr)
		l = []
		for k in pkeys:
			l.append(str(k) + ":" + _getSortedString(o[k]))
		return "{" + join(l, ",") + "}"
	else:
		return str(o)
451500
protected void sortIndexMap() {
        for (Iterator<List<Doc>> it = indexmap.values().iterator(); it.hasNext(); ) {
            Collections.sort(it.next(), new DocComparator());
        }
    }
1063683
def sorted_key_list(self):
        """"""
        if not self.is_baked:
            self.bake()
        key_value_tuple = sorted(self.dct.items(),
                                 key=lambda x: x[1]['__abs_time__'])
        skl = [k[0] for k in key_value_tuple]
        return skl
137665
def sortBy(self, *args):
        ''''''
        criteria = ['seeds', 'size']
        for k in args:
            if k in criteria:
                self.results = sorted(
                    self.results, key=attrgetter(k), reverse=True)
        return self
93051
def completions_sorting_key(cls, word):
        ""
        prio1, prio2 = 0, 0
        if word.startswith('__'):  prio1 = 2
        elif word.startswith('_'): prio1 = 1
        if word.endswith('='):     prio1 = -1
        if word.startswith('%%'):
            if not "%" in word[2:]:
                word = word[2:];   prio2 = 2
        elif word.startswith('%'):
            if not "%" in word[1:]:
                word = word[1:];   prio2 = 1
        return prio1, word, prio2
1246517
def resolve_sorting(self, query):
        
        sorting = {}

        # Sort on
        sort_on = query.get("sidx", None)
        sort_on = sort_on or query.get("sort_on", None)
        sort_on = sort_on == "Title" and "sortable_title" or sort_on
        if sort_on:
            sorting["sort_on"] = sort_on

            # Sort order
            sort_order = query.get("sord", None)
            sort_order = sort_order or query.get("sort_order", None)
            if sort_order in ["desc", "reverse", "rev", "descending"]:
                sorting["sort_order"] = "descending"
            else:
                sorting["sort_order"] = "ascending"

            # Sort limit
            sort_limit = api.to_int(query.get("limit", 30), default=30)
            if sort_limit:
                sorting["sort_limit"] = sort_limit

        return sorting
537504
private static void sortKeyPrefixArrayAtByte(
      LongArray array, long numRecords, long[] counts, int byteIdx, long inIndex, long outIndex,
      boolean desc, boolean signed) {
    assert counts.length == 256;
    long[] offsets = transformCountsToOffsets(
      counts, numRecords, array.getBaseOffset() + outIndex * 8L, 16, desc, signed);
    Object baseObject = array.getBaseObject();
    long baseOffset = array.getBaseOffset() + inIndex * 8L;
    long maxOffset = baseOffset + numRecords * 16L;
    for (long offset = baseOffset; offset < maxOffset; offset += 16) {
      long key = Platform.getLong(baseObject, offset);
      long prefix = Platform.getLong(baseObject, offset + 8);
      int bucket = (int)((prefix >>> (byteIdx * 8)) & 0xff);
      long dest = offsets[bucket];
      Platform.putLong(baseObject, dest, key);
      Platform.putLong(baseObject, dest + 8, prefix);
      offsets[bucket] += 16;
    }
  }
618628
def get_sorted_tags(self, pattern):
        
        matcher = re.compile(pattern)
        tags = []
        for tag in self.get_repo().git.tag().split('\n'):
            m = matcher.match(tag)
            if m:
                numbers = []
                for k, v in m.groupdict().items():
                    if k.startswith('cmp'):
                        numbers.append((int(k[3:]), int(v)))
                numbers.sort()

                tags.append((tag, numbers))
        return map(lambda t: t[0], sorted(tags, key=lambda t: t[1], reverse=True))
1160254
def _sort_by_sortedset_before(self):
        
        return self._sort_by_sortedset and self._sort_limits and (not self._lazy_collection['pks']
                                                            or self._want_score_value)
148877
def sort_labeled_issues(issues)
      sorted_issues = []
      issues.each do |issue|
        label_names = issue["labels"].collect { |l| l["name"] }

        # Add PRs in the order of the @sections array. This will either be the
        # default sections followed by any --add-sections sections in
        # user-defined order, or --configure-sections in user-defined order.
        # Ignore the order of the issue labels from github which cannot be
        # controled by the user.
        @sections.each do |section|
          unless (section.labels & label_names).empty?
            section.issues << issue
            sorted_issues << issue
            break
          end
        end
      end
      issues - sorted_issues
    end
402376
def _citation_sort_key(t: EdgeTuple) -> str:
    """"""
    return '"{}", "{}"'.format(t[3][CITATION][CITATION_TYPE], t[3][CITATION][CITATION_REFERENCE])
131446
def sort_permutations(permutations, user_deps)
      # Cache for versions converted to Gem::Version instances
      versions = {}

      map = lambda do |m, p|
        if p =~ Lyp::PACKAGE_RE
          m[$1] = versions[p] ||= (Lyp.version($2 || '0.0') rescue nil)
        end
        m
      end

      compare = lambda do |x, y|
        x_versions = x.inject({}, &map)
        y_versions = y.inject({}, &map)

        # If the dependency is direct (not transitive), just compare its versions.
        # Otherwise, add the result of comparison to score.
        x_versions.inject(0) do |score, kv|
          package = kv[0]
          cmp = kv[1] <=> y_versions[package]
          if user_deps.include?(package) && cmp != 0
            return cmp
          else
            score += cmp unless cmp.nil?
          end
          score
        end
      end

      permutations.sort(&compare)
    end
860991
def dflt_sortby_objgoea(goea_res):
        """"""
        return [getattr(goea_res, 'enrichment'),
                getattr(goea_res, 'namespace'),
                getattr(goea_res, 'p_uncorrected'),
                getattr(goea_res, 'depth'),
                getattr(goea_res, 'GO')]
197088
def canonical_chrom_sorted(in_chroms):
    
    if len(in_chroms) == 0:
        return []
    chr_prefix = False
    mt = False
    if in_chroms[0].startswith('chr'):
        in_chroms = [x.lstrip('chr') for x in in_chroms]
        chr_prefix = True
    if 'MT' in in_chroms:
        in_chroms[in_chroms.index('MT')] = 'M'
        mt = True
    in_chroms = sorted(in_chroms, key=lambda c: int(c) if c not in ('X', 'Y', 'M') else c)
    try:
        m_index = in_chroms.index('M')
    except ValueError:
        pass
    else:
        in_chroms.pop(m_index)
        in_chroms.append('M')
    # At this point it should be nicely sorted
    if mt:
        in_chroms[in_chroms.index('M')] = 'MT'
    if chr_prefix:
        in_chroms = [''.join(['chr', x]) for x in in_chroms]
    return in_chroms
1188867
def sort_annotations(annotations: List[Tuple[int, int, str]]
                     ) -> List[Tuple[int, int, str]]:
    
    return sorted(annotations, key=lambda x: x[0])
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)