~garritfra/antimony

antimony/examples/bubblesort.sb -rw-r--r-- 429 bytes
36db9aecGarrit Franke remove accidental test file 1 year, 1 month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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 += 1
        }

        c += 1
    }

    println(arr)
}