Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,31 @@
|
|||
class BubbleSort
|
||||
**Sort a list with the Bubble Sort algorithm**
|
||||
|
||||
on start
|
||||
|
||||
args := program arguments
|
||||
.sort(args)
|
||||
print args
|
||||
|
||||
define sort(list) is shared
|
||||
**Sort the list**
|
||||
|
||||
test
|
||||
list := [4, 2, 7, 3]
|
||||
.sort(list)
|
||||
assert list = [2, 3, 4, 7]
|
||||
|
||||
body
|
||||
last := list.count - 1
|
||||
|
||||
post while changed
|
||||
|
||||
changed := false
|
||||
|
||||
for i in last
|
||||
|
||||
if list[i] > list[i + 1]
|
||||
temp := list[i]
|
||||
list[i] := list[i + 1]
|
||||
list[i + 1] := temp
|
||||
changed := true
|
||||
Loading…
Add table
Add a link
Reference in a new issue