Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,21 @@
|
|||
procedure main() #: demonstrate various ways to sort a list and string
|
||||
demosort(shellsort,[3, 14, 1, 5, 9, 2, 6, 3],"qwerty")
|
||||
end
|
||||
|
||||
procedure shellsort(X,op) #: return sorted X
|
||||
local i,j,inc,temp
|
||||
|
||||
op := sortop(op,X) # select how and what we sort
|
||||
|
||||
inc := *X/2
|
||||
while inc > 0 do {
|
||||
every i := inc to *X do {
|
||||
temp := X[j := i]
|
||||
while op(temp,X[j - (j >= inc)]) do
|
||||
X[j] := X[j -:= inc]
|
||||
X[j] := temp
|
||||
}
|
||||
inc := if inc = 2 then 1 else inc*5/11 # switch to insertion near the end
|
||||
}
|
||||
return X
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue