上上题qSort()函数不支持排序规则函数,形如sorted()函数的key参数,为实现类似目标,横线处分别应填入代码是( )。

fi746491 单选题 共 个子题
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

正在加载题目数据…
已答 /
子题
该题型需在试卷/作业中作答,单题练习暂不支持
答案解析
讨论
发布
登录后参与讨论 立即登录
发布讨论需先绑定并验证手机号 去绑定手机号
加载中…
我
我
回复 @
回复 @
发送
还没有人讨论,来发表第一条吧