Anonymous user
Sorting algorithms/Bubble sort: Difference between revisions
→[[Toka]]: Updated to work with Toka R1
(add E example) |
(→[[Toka]]: Updated to work with Toka R1) |
||
Line 379:
[[Category:Toka]]
Toka
#! A simple Bubble Sort function
value| array count changed |
[ ( address count -- )
to count to array
count 0
[ count 0
[ i array array.get
[ i array array.put
[ 2drop ] ifTrueFalse
]
count 1 - to count
]
] is bsort
#! Code to display an array
[ ( array count -- )
0 swap [ dup i swap array.get
] is .array
Line 413 ⟶ 404:
#! Fill it with random values
20 1 foo array.put
50 2 foo array.put
650 3 foo array.put
120 4 foo array.put
110 5 foo array.put
101 6 foo array.put
1321 7 foo array.put
1310 8 foo array.put
987 9 foo array.put
10 10 foo array.put
#! Display the array, sort it, and display it again
|