Python __builtin__ 模块,sorted() 实例源码

我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用__builtin__.sorted()

项目:Deep-Subspace-Clustering    作者:tonyabracadabra    | 项目源码 | 文件源码
def fullfile(*args):
    return os.path.join(*args)

# implemented in "scripts/set/intersect.m"
#def intersect(a,b,nargout=1):
#    if nargout == 1:
#        c = sorted(set(a) & set(b))
#        if isinstance(a,str):
#            return "".join(c)
#        elif isinstance(a,list):
#            return c
#        else:
#            # FIXME: the result is a column vector if
#            # both args are column vectors; otherwise row vector
#            return np.array(c)
#    raise NotImplementedError
#
项目:histwords    作者:williamleif    | 项目源码 | 文件源码
def get_vocab(data):
    vocab = set()
    for analogy in data:
        vocab.update(analogy)
    vocab = sorted(vocab)
    return dict([(a, i) for i, a in enumerate(vocab)]), vocab
项目:idascripts    作者:ctfhacker    | 项目源码 | 文件源码
def flazy(f, *a, **k):
    sortedtuple, state = fcompose(__builtin__.sorted, __builtin__.tuple), {}
    def lazy(*ap, **kp):
        A, K = a+ap, sortedtuple(k.items() + kp.items())
        return state[(A,K)] if (A,K) in state else state.setdefault((A,K), f(*A, **__builtin__.dict(k.items()+kp.items())))
    return lazy
项目:watcher    作者:nosmokingbandit    | 项目源码 | 文件源码
def reversed(data):
            if not isinstance(data, list):
                data = list(data)
            reversed_data = []
            for index in xrange(len(data)-1, -1, -1):
                reversed_data.append(data[index])
            return reversed_data

# --- sorted() from Python 2.4 ---
项目:watcher    作者:nosmokingbandit    | 项目源码 | 文件源码
def sorted(data):
        sorted_data = copy.copy(data)
        sorted_data.sort()
        return sorted