mirror of https://git.sr.ht/~garritfra/sabre
Garrit Franke
3 years ago
3 changed files with 72 additions and 2 deletions
@ -0,0 +1,25 @@ |
|||||||
|
// Doesn't compile yet |
||||||
|
|
||||||
|
fn main() { |
||||||
|
let arr = [2, 5, 3, 1, 4] |
||||||
|
let n = len(arr) |
||||||
|
|
||||||
|
let c = 0 |
||||||
|
while c < n { |
||||||
|
let d = 0 |
||||||
|
while d < n - c - 1 { |
||||||
|
let current = arr[d] |
||||||
|
let next = arr[d+1] |
||||||
|
if current > next { |
||||||
|
let swap = arr[d] |
||||||
|
arr[d] = arr[d+1] |
||||||
|
arr[d+1] = swap |
||||||
|
} |
||||||
|
|
||||||
|
d = d + 1 |
||||||
|
} |
||||||
|
|
||||||
|
c = c + 1 |
||||||
|
} |
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue