(array []int)
| 1 | package CombSort |
| 2 | |
| 3 | func CombSort(array []int) { |
| 4 | gapValue := len(array) |
| 5 | swapCount := 1 |
| 6 | for gapValue >= 1 && swapCount != 0 { |
| 7 | if gapValue != 1 { |
| 8 | gapValue = int(float64(gapValue) / float64(1.3)) |
| 9 | } |
| 10 | swapCount = 0 |
| 11 | firstItem := 0 |
| 12 | secondItem := gapValue |
| 13 | for secondItem != len(array) { |
| 14 | if array[firstItem] > array[secondItem] { |
| 15 | array[firstItem], array[secondItem] = array[secondItem], array[firstItem] |
| 16 | swapCount += 1 |
| 17 | } |
| 18 | firstItem += 1 |
| 19 | secondItem += 1 |
| 20 | } |
| 21 | } |
| 22 | } |