diff options
| author | Martial Simon <msimon_fr@hotmail.com> | 2025-09-15 01:07:58 +0200 |
|---|---|---|
| committer | Martial Simon <msimon_fr@hotmail.com> | 2025-09-15 01:07:58 +0200 |
| commit | 967be9e750221ab2ab783f95df79bb26d290a45e (patch) | |
| tree | 6802900a5e975f9f68b169f0f503f040056d6952 /tigrou/sort/sort.tih | |
Diffstat (limited to 'tigrou/sort/sort.tih')
| -rw-r--r-- | tigrou/sort/sort.tih | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tigrou/sort/sort.tih b/tigrou/sort/sort.tih new file mode 100644 index 0000000..c601fe3 --- /dev/null +++ b/tigrou/sort/sort.tih @@ -0,0 +1,24 @@ +type int_array = array of int +function sort(a : int_array, size : int) = + if size > 0 then + ( + let var swapped := 0 + in + for i := 0 to size do + ( + swapped := 0; + (for j := 1 to size - i - 1 do + if a[j - 1] > a[j] then + ( + (let var tmp := a[j - 1] + in + a[j - 1] := a[j]; + a[j] := tmp + end); + swapped := 1 + )); + if swapped = 0 then + break + ) + end + ) |
