We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents dd65dd3 + 13e206e commit 3438c48Copy full SHA for 3438c48
sorts/bubble_sort.go
@@ -2,23 +2,15 @@
2
package sorts
3
4
func bubbleSort(arrayzor []int) []int {
5
-
6
7
swapped := true
8
for swapped {
9
swapped = false
10
for i := 0; i < len(arrayzor)-1; i++ {
11
if arrayzor[i+1] < arrayzor[i] {
12
- swap(arrayzor, i, i+1)
+ arrayzor[i+1], arrayzor[i] = arrayzor[i], arrayzor[i+1]
13
swapped = true
14
}
15
16
17
return arrayzor
18
19
20
-func swap(arrayzor []int, i, j int) {
21
- tmp := arrayzor[j]
22
- arrayzor[j] = arrayzor[i]
23
- arrayzor[i] = tmp
24
-}
0 commit comments