-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
您的答案 (Your Solution)
import copy
def bubble_sort(numbers: list[int]) -> list[int]:
"""
使用冒泡排序算法对一个数字列表进行升序排序。
:param numbers: 一个数字列表
:return: 排序后的新列表(为了不修改原始列表)
"""
# https://www.runoob.com/w3cnote/bubble-sort.html 参考这个实现
result:list[int] = copy.deepcopy(numbers)
length = len(result)
for i in range(0, length):
for j in range(length - 1 - i):
if result[j] > result[j + 1]:
result[j], result[j + 1] = result[j + 1], result[j]
return result解题思路 (Thought Process)
No response
其他信息 (Additional context)
No response