对列表[[3,5,7],8,[2,9,6,4]]排序,拍完后为[[2,3,4],5,[6,7,8,9]] l1=[[3,5,7],8,[2,9,6,4]] l3=[] for i in l1: if type(i) is int: l3.append(i) else: for j in i: l3.append(j) l3.sort(reverse=False) print(l3) b=0 for i in range(len(l1)): if type(l1[i]) is int: l1[i]=l3[b] b+=1 else: for j in range(len(l1[i])): l1[i][j] = l3[b] b=b+1 print(l1)
二维列表排序
最新推荐文章于 2024-08-15 01:55:01 发布