all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
|
|
@ -0,0 +1,57 @@
|
|||
/* NetRexx */
|
||||
options replace format comments java crossref savelog symbols binary
|
||||
|
||||
placesList = [String -
|
||||
"UK London", "US New York" -
|
||||
, "US Boston", "US Washington" -
|
||||
, "UK Washington", "US Birmingham" -
|
||||
, "UK Birmingham", "UK Boston" -
|
||||
]
|
||||
sortedList = cocktailSort(String[] Arrays.copyOf(placesList, placesList.length))
|
||||
|
||||
lists = [placesList, sortedList]
|
||||
loop ln = 0 to lists.length - 1
|
||||
cl = lists[ln]
|
||||
loop ct = 0 to cl.length - 1
|
||||
say cl[ct]
|
||||
end ct
|
||||
say
|
||||
end ln
|
||||
|
||||
return
|
||||
|
||||
method cocktailSort(A = String[]) public constant binary returns String[]
|
||||
|
||||
Alength = A.length
|
||||
swapped = isFalse
|
||||
loop label swapped until \swapped
|
||||
swapped = isFalse
|
||||
loop i_ = 0 to Alength - 2
|
||||
if A[i_].compareTo(A[i_ + 1]) > 0 then do
|
||||
swap = A[i_ + 1]
|
||||
A[i_ + 1] = A[i_]
|
||||
A[i_] = swap
|
||||
swapped = isTrue
|
||||
end
|
||||
end i_
|
||||
if \swapped then do
|
||||
leave swapped
|
||||
end
|
||||
swapped = isFalse
|
||||
loop i_ = Alength - 2 to 0 by -1
|
||||
if A[i_].compareTo(A[i_ + 1]) > 0 then do
|
||||
swap = A[i_ + 1]
|
||||
A[i_ + 1] = A[i_]
|
||||
A[i_] = swap
|
||||
swapped = isTrue
|
||||
end
|
||||
end i_
|
||||
end swapped
|
||||
|
||||
return A
|
||||
|
||||
method isTrue public constant binary returns boolean
|
||||
return 1 == 1
|
||||
|
||||
method isFalse public constant binary returns boolean
|
||||
return \isTrue
|
||||
Loading…
Add table
Add a link
Reference in a new issue