util.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:prysm 作者: brandondube 项目源码 文件源码
def sort_xy(x, y):
    ''' Sorts a pair of x and y iterables, returning arrays in order of
        ascending x.

    Args:
        x (`iterable`): a list, numpy ndarray, or other iterable to sort by.

        y (`iterable`): a list, numpy ndarray, or other iterable that is y=f(x).

    Returns:
        tuple containing:
            `iterable`: an iterable containing the sorted x elements.

            `iterable`: an iterable containing the sorted y elements.

    '''
    # zip x and y, sort by the 0th element (x) of each tuple in zip()
    _ = sorted(zip(x, y), key=itemgetter(0))
    sorted_x, sorted_y = zip(*_)
    return sorted_x, sorted_y
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号