This commit is contained in:
Ingy döt Net 2013-06-05 21:47:54 +00:00
parent 1f1ad49427
commit 6f050a029e
2496 changed files with 37609 additions and 3031 deletions

View file

@ -20,8 +20,8 @@ struct {
int CmprRows( const void *aa, const void *bb)
{
String *rA = *(String **)aa;
String *rB = *(String **)bb;
String *rA = *(String *const *)aa;
String *rB = *(String *const *)bb;
int sortCol = sortSpec.column;
String left = sortSpec.reversed ? rB[sortCol] : rA[sortCol];
@ -66,7 +66,7 @@ int sortTable(Table tbl, const char* argSpec,... )
}
}
va_end(vl);
qsort( tbl->rows, tbl->n_rows, sizeof(String *), &CmprRows);
qsort( tbl->rows, tbl->n_rows, sizeof(String *), CmprRows);
return 0;
}

View file

@ -0,0 +1,19 @@
sortStrings: procedure expose @. /*stemmed array is named: @. */
col=1; reverse='NO'; order='LEXICOGRAPHIC' /*set the defaults.*/
arg options
do j=1 for words(options); x=word(options,j)
select
when datatype(x,'W') then col=x/1
when pos('=',x)==0 then order=x
otherwise parse var x nam '=' value
end /*select*/
end /*j*/
/*check for errors here: COL isn't positive, */
/* REVERSE value isn't NO or YES, */
/* ORDER value is recognized ... */
... main body of string sort here ...
return

View file

@ -0,0 +1,4 @@
/*REXX example to use the SortStrings subroutine with optional args. */
/*...define array (@.nnn) of strings here...*/
call sortStrings 'Reverse=no' 3
/*stick a fork in it, we're done.*/