all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
|
|
@ -0,0 +1,17 @@
|
|||
procedure main() #: demonstrate various ways to sort a list and string
|
||||
demosort(selectionsort,[3, 14, 1, 5, 9, 2, 6, 3],"qwerty")
|
||||
end
|
||||
|
||||
|
||||
procedure selectionsort(X,op) #: return sorted list ascending(or descending)
|
||||
local i,m
|
||||
|
||||
op := sortop(op,X) # select how and what we sort
|
||||
every i := 1 to *X-1 do {
|
||||
m := i
|
||||
every j := i + 1 to *X do
|
||||
if op(X[j],X[m]) then m := j # find X that belongs @i low (or high)
|
||||
X[m ~= i] :=: X[m]
|
||||
}
|
||||
return X
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue