第14357题 单选题
补全支持类似sorted的key参数的qSort快速排序函数的横线处代码,正确选项是?

qSort()函数需要实现类似sorted()函数的key参数的排序规则功能,补全下列代码中横线处的内容,正确的是()。

def qSort(lst, fx = None):
    if len(lst) <= 1:
        return lst
    else:
        Pivot = lst[0]
        if __________:
            Less = [x for x in lst[1:] if __________]
            Greater = [x for x in lst[1:] if __________]
            return qSort(Less,fx) + [Pivot] + qSort(Greater,fx)
        else:
            Less = [x for x in lst[1:] if x <= Pivot]
            Greater = [x for x in lst[1:] if x > Pivot]
            return qSort(Less,fx) + [Pivot] + qSort(Greater,fx)

lstA = [1,2,11,12,21,21,2,3,41,4,3]
lstB = qSort(lstA, lambda x:x % 10)
print(lstA, lstB)
A

fx==None,fx(x)>=fx(Pivot),fx(x)<fx(Pivot)

B

fx==None,fx(x)>=Pivot,fx(x)<Pivot

C

fx !=None,fx(x)>=fx(Pivot),fx(x)<fx(Pivot)

D

fx !=None,fx(x)>=Pivot,fx(x)<Pivot

程序运行统计
暂无判题统计