Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,37 @@
|
|||
program SortExample
|
||||
|
||||
function main()
|
||||
test1 string[] = ["Here", "are", "some", "sample", "strings", "to", "be", "sorted"];
|
||||
test1.sort(sortFunction);
|
||||
|
||||
SysLib.writeStdout("Test 1:");
|
||||
for(i int from 1 to test1.getSize())
|
||||
SysLib.writeStdout(test1[i]);
|
||||
end
|
||||
|
||||
test2 string[] = ["Cat", "apple", "Adam", "zero", "Xmas", "quit", "Level", "add", "Actor", "base", "butter"];
|
||||
test2.sort(sortFunction);
|
||||
|
||||
SysLib.writeStdout("Test 2:");
|
||||
for(i int from 1 to test2.getSize())
|
||||
SysLib.writeStdout(test2[i]);
|
||||
end
|
||||
end
|
||||
|
||||
function sortFunction(a any in, b any in) returns (int)
|
||||
result int = (b as string).length() - (a as string).length();
|
||||
if (result == 0)
|
||||
case
|
||||
when ((a as string).toLowerCase() > (b as string).toLowerCase())
|
||||
result = 1;
|
||||
when ((a as string).toLowerCase() < (b as string).toLowerCase())
|
||||
result = -1;
|
||||
otherwise
|
||||
result = 0;
|
||||
end
|
||||
end
|
||||
|
||||
return result;
|
||||
end
|
||||
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue