ターン:Pythonは演習のリストをソートし、4つの方法

ます。https://www.cnblogs.com/tttzqf/p/9270509.htmlこれは、アドレスをTTT週間の風を切り替えます

 

DEF sort_list_method_1()
    リターン()ソート


(sort_list_method_1([1、4,2]))印刷


:DEF sort_list_method_2()
    の範囲でiについて(LEN()):
        M = I
        の範囲内のZ(iについて+1、lenの()):
            [M]場合> [Z]:
                M = Z
        A [m]は、[I] = [I]、[M]
    戻り


プリント(sort_list_method_2を([2 、4、1]))


DEF sort_list_method_3():
    B = []
    のIの範囲内(LEN()):
        b.append(MIN())
        a.remove(MIN())
    戻りBの


印刷( sort_list_method_3([4、2、-2、8]))


DEF sort_list_method_4():
        リターンa.sort()


B = [4、3、7、-2、1]
sort_list_method_4(b)の
印刷(B)

おすすめ

転載: www.cnblogs.com/cbma0116/p/11881159.html