selection_sort

  • 2022-12-14
  • 浏览 (580)

selection_sort.py 源码

import random
from typing import List

# 选择排序


def selectionSort(data: List[int]):
    length = len(data)
    if length <= 1:
        return

    for i in range(length - 1):
        least = i
        for j in range(i + 1, length):
            if data[j] < data[least]:
                least = j
        data[i], data[least] = data[least], data[i]

你可能感兴趣的文章

bubble_sort

insertion_sort

merge_sort

0  赞