python十大经典排序算法动图讲解
http://www.cnblogs.com/wuxinyan/p/8615127.html
字典序排序算法的python范例代码:
https://blog.csdn.net/u011444756/article/details/79914245
字典序排序算法的详细讲解及C代码:
https://blog.csdn.net/asddasads/article/details/79863754
按照查字典的排序方法排序list
str5 = ['adf', 'a', 'b', 'cas', '23', '32', '7']
# str5 = [3, 5, 7, 3, 7, 9]
for i in range(len(str5)):
for j in range(0, len(str5)-i-1): # 前面这两个for循环借用冒泡排序的
if(len(str5[j]) < len(str5[j+1])):
length = len(str5[j])
else:
length = len(str5[j+1])
for k in range(length): # 下面则进行仿照查字典的排序方法
if(ord(str5[j][k]) > ord(str5[j+1][k])):
str5[j], str5[j+1] = str5[j+1], str5[j]
break
elif (ord(str5[j][k]) < ord(str5[j + 1][k])):
break
print(str5)
Python的22个编程技巧,简化 if 语句、开启文件分享:
https://blog.csdn.net/j2iayu7y/article/details/80288457
python 中如何将数字print输出中,去掉最后一个逗号:
https://www.cnblogs.com/yangyi54920/p/11031676.html
我之前写的是:
xlist = [1, 5, 4, 3, 2, 6]
print(str(xlist)[1:len(str(xlist)) - 1].replace(',', ''))
逻辑复杂,但是一行代码。