mirror of https://git.sr.ht/~garritfra/sabre
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
441 B
25 lines
441 B
3 years ago
|
// 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
|
||
|
}
|
||
|
|
||
|
}
|