Hello all!

The logic END-ALL SORT … END-SORT has a very bad performance for small amounts of data on our system - i.e. small arrays.

So here’s my quick’n’dirty implementation of a bubble sort. Please feel free to improve it - but please let the community know your improvements.

```
define data parameter
1 #sorting-tab(1:*)
2 #values (A) dynamic
2 #indexes (I4) /* e.g. for referencing a table-line
*
local
*
1 #index (I4)
1 #value (B) dynamic
*
1 #i (I4)
1 #n (I4)
1 #newn (I4)
1 #occ-1 (I4)
end-define
*
#n := *OCC(#sorting-tab.#values)
repeat
*
#newn := 2
#occ-1 := #n - 1
for #i = 1 to #occ-1
if #sorting-tab.#values(#i) > #sorting-tab.#values(#i + 1)
*
#value := #sorting-tab.#values(#i)
#sorting-tab.#values(#i) := #sorting-tab.#values(#i + 1)
#sorting-tab.#values(#i + 1) := #value
#index := #sorting-tab.#indexes(#i)
#sorting-tab.#indexes(#i) := #sorting-tab.#indexes(#i + 1)
#sorting-tab.#indexes(#i + 1) := #index
*
#newn := #i + 1
end-if
end-for
#n := #newn
*
if #n <= 2
escape bottom
end-if
end-repeat
*
end
```

regards

Matthias