对python数组进行排序

Hul*_*ulk 1 python sorting

opt=[]
opt=["opt3","opt2","opt7","opt6","opt1"]
for i in range(len(opt)):
     print opt[i]
Run Code Online (Sandbox Code Playgroud)

上面的输出是

opt3,opt2,opt7,opt6,opt1
Run Code Online (Sandbox Code Playgroud)

如何按升序对上面的数组进行排序

Nul*_*ion 7

.sort()如果要对原始列表进行排序,请使用此选项.(opt.sort())

sorted()如果您想要它的排序副本,请使用.