Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,32 @@
|
|||
/* NetRexx */
|
||||
options replace format comments java crossref symbols nobinary
|
||||
|
||||
-- =============================================================================
|
||||
class RSortCustomComparator public
|
||||
|
||||
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
method main(args = String[]) public static
|
||||
sample = [String 'Here', 'are', 'some', 'sample', 'strings', 'to', 'be', 'sorted']
|
||||
say displayArray(sample)
|
||||
Arrays.sort(sample, LengthComparator())
|
||||
say displayArray(sample)
|
||||
return
|
||||
|
||||
method displayArray(harry = String[]) constant
|
||||
disp = ''
|
||||
loop elmt over harry
|
||||
disp = disp','elmt
|
||||
end elmt
|
||||
return '['disp.substr(2)']' -- trim leading comma
|
||||
|
||||
-- =============================================================================
|
||||
class RSortCustomComparator.LengthComparator implements Comparator
|
||||
|
||||
method compare(lft = Object, rgt = Object) public binary returns int
|
||||
cRes = int
|
||||
if lft <= String, rgt <= String then do
|
||||
cRes = (String rgt).length - (String lft).length
|
||||
if cRes == 0 then cRes = (String lft).compareToIgnoreCase(String rgt)
|
||||
end
|
||||
else signal IllegalArgumentException('Arguments must be Strings')
|
||||
return cRes
|
||||
Loading…
Add table
Add a link
Reference in a new issue