MCPcopy Create free account
hub / github.com/Jack-Lee-Hiter/AlgorithmsByPython / selectionSort

Function selectionSort

SelectionSort.py:2–9  ·  view source on GitHub ↗
(alist)

Source from the content-addressed store, hash-verified

1# 选择排序, 纯粹练手 - -||
2def selectionSort(alist):
3 for i in range(len(alist)-1):
4 min = i
5 for j in range(i+1, len(alist)):
6 if alist[j] < alist[min]:
7 min = j
8 alist[i], alist[min] = alist[min], alist[i]
9 return alist
10
11alist = [54,26,93,17,77,31,44,55,20]
12print(selectionSort(alist))

Callers 1

SelectionSort.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected