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