其他分享
首页 > 其他分享> > 字符串冒泡排序方法

字符串冒泡排序方法

作者:互联网

def str_bubble(s1):
    if s1:
        if isinstance(s1[0], int):
            n = len(s1)
            s1 = list(map(lambda x: str(x), s1))
        else:
            pass
        for i in range(n):
            for j in range(i + 1, n):
                if int(s1[i] + s1[j]) > int(s1[j] + s1[i]):
                    pass
                else:
                    s1[i], s1[j] = s1[j], s1[i]
    return s1

 

标签:int,s1,冒泡排序,else,range,str,pass,字符串,方法
来源: https://www.cnblogs.com/icxk/p/16437036.html