how high in sorted list each key is. inverse permutation of sorter, such that sorted[rank]==keys
197765
def rank(self):
        """"""
        r = np.empty(self.size, np.int)
        r[self.sorter] = np.arange(self.size)
        return r
212699
def sort_idx(m, reverse=False):
    """"""
    return sorted(range(len(m)), key=lambda k: m[k], reverse=reverse)
537232
def is_sorted(self, ranks=None):
        
        ranks = ranks or self.ranks

        return check_sorted(self, ranks)
1099723
def sorted(self, iterator, key=None, reverse=False):
        
        global MemoryBytesSpilled, DiskBytesSpilled
        batch, limit = 100, self._next_limit()
        chunks, current_chunk = [], []
        iterator = iter(iterator)
        while True:
            # pick elements in batch
            chunk = list(itertools.islice(iterator, batch))
            current_chunk.extend(chunk)
            if len(chunk) < batch:
                break

            used_memory = get_used_memory()
            if used_memory > limit:
                # sort them inplace will save memory
                current_chunk.sort(key=key, reverse=reverse)
                path = self._get_path(len(chunks))
                with open(path, 'wb') as f:
                    self.serializer.dump_stream(current_chunk, f)

                def load(f):
                    for v in self.serializer.load_stream(f):
                        yield v
                    # close the file explicit once we consume all the items
                    # to avoid ResourceWarning in Python3
                    f.close()
                chunks.append(load(open(path, 'rb')))
                current_chunk = []
                MemoryBytesSpilled += max(used_memory - get_used_memory(), 0) << 20
                DiskBytesSpilled += os.path.getsize(path)
                os.unlink(path)  # data will be deleted after close

            elif not chunks:
                batch = min(int(batch * 1.5), 10000)

        current_chunk.sort(key=key, reverse=reverse)
        if not chunks:
            return current_chunk

        if current_chunk:
            chunks.append(iter(current_chunk))

        return heapq.merge(chunks, key=key, reverse=reverse)
1132997
function sortedKeys(obj, orderedKeys) {
    var keys = Object.keys(obj).sort();
    var fresh = {};

    orderedKeys.forEach(function (key) {
        if (keys.indexOf(key) === -1) {
            return;
        }

        fresh[key] = obj[key];
    });

    keys.forEach(function (key) {
        if (orderedKeys.indexOf(key) !== -1) {
            return;
        }

        fresh[key] = obj[key];
    });

    return fresh;
}
1135507
def sorted_args(self):
        
        return sorted(self.args,
                      key=lambda x: x.is_flag or x.can_be_inferred)
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
782178
def sorted_t(key=None, reverse=False):
    
    return Transformation(
        'sorted',
        lambda sequence: sorted(sequence, key=key, reverse=reverse),
        None
    )
138260
def sort(m, reverse=False):
    """"""
    ty = type(m)
    if ty == matrix:
        m = list(m)
    m = sorted(m, reverse=reverse)
    if ty == matrix:
        m = matrix(m)
    return m
1240912
def sort_dict(self, data, key):
    ''''''
    return sorted(data, key=itemgetter(key)) if data else []
417078
private static <K extends Comparable<? super K>, V> Collection<@KeyFor("#1") K> sortedKeySet(
      Map<K, V> m) {
    ArrayList<@KeyFor("#1") K> theKeys = new ArrayList<>(m.keySet());
    Collections.sort(theKeys);
    return theKeys;
  }
1227974
def select_highest_ranked (elements, ranks):
    
    assert is_iterable(elements)
    assert is_iterable(ranks)
    if not elements:
        return []

    max_rank = max_element (ranks)

    result = []
    while elements:
        if ranks [0] == max_rank:
            result.append (elements [0])

        elements = elements [1:]
        ranks = ranks [1:]

    return result
1221143
def sorted(self, key=None, reverse=False):
        
        return self._transform(transformations.sorted_t(key=key, reverse=reverse))
923601
def unsort(self, array):
        
        if self.sorted:
            inverse = sorted(enumerate(self.indices), key=itemgetter(1))
            array = [array[i[0]] for i in inverse]
        return array
494343
private void fixupMinWithComparator(int k) {
        K key = array[k];
        int gp = k / 4;
        while (gp > 0 && comparator.compare(array[gp], key) > 0) {
            array[k] = array[gp];
            k = gp;
            gp = k / 4;
        }
        array[k] = key;
    }
733960
def keys(self, key=None, reverse=False):
        """"""
        ks = sorted(list(dict.keys(self)), key=key, reverse=reverse)
        return ks
881437
def order_by_descending(self, key):
        
        if key is None:
            raise NullArgumentError(u"No key for sorting given")
        kf = [OrderingDirection(key, reverse=True)]
        return SortedEnumerable3(kf, self._data)