Bubbling: The first lie moves the largest number to the last

func bubbleSort(arr []int) { if len(arr) < 1 { return } for i := 0; i < len(arr) - 1; For j := 0; j < len(arr) - i - 1; J++ {/ / traverse from scratch if arr [j] > arr [m + 1] {arr [j], arr = arr [m + 1] [j + 1], arr [j] / / swap}}}}Copy the code

Select: find the minimum subscript on the first trip, and swap with the first number

func selectSort(arr []int) { if len(arr) < 1 { return } for i := 0; i < len(arr) - 1; K := I for j := I + 1; j < len(arr); j++ { if arr[j] < arr[k] { k = j } } arr[i], arr[k] = arr[k], arr[i] } }Copy the code