## Array Sort order

## Array Sort order

(OP)

thread767-1553861: Sorting Summary labels in an array

???? //-1 for ascending order ??????

This code is great but I can't get it Ascending !!!! I have put -1 in various places and it gives error

WhilePrintingRecords;

stringvar Array codes := split({@array}, ", ");

stringvar Array result;

redim preserve result[ubound(codes)];

Numbervar k;

NumberVar p;

stringvar y;

numbervar i;

for k := 1 to ubound(codes) do

(

result[k] := trim(Maximum(codes));

for p := 1 to ubound(codes) do

(

if trim(codes[p]) = result[k] then

(

codes[p] := "";

Exit For;

);

);

);

for i := 1 to ubound(result) do (

y := y + result[-i] + ", " //-1 for ascending order

);

trim(left(y,len(y)-2));

???? //-1 for ascending order ??????

This code is great but I can't get it Ascending !!!! I have put -1 in various places and it gives error

WhilePrintingRecords;

stringvar Array codes := split({@array}, ", ");

stringvar Array result;

redim preserve result[ubound(codes)];

Numbervar k;

NumberVar p;

stringvar y;

numbervar i;

for k := 1 to ubound(codes) do

(

result[k] := trim(Maximum(codes));

for p := 1 to ubound(codes) do

(

if trim(codes[p]) = result[k] then

(

codes[p] := "";

Exit For;

);

);

);

for i := 1 to ubound(result) do (

y := y + result[-i] + ", " //-1 for ascending order

);

trim(left(y,len(y)-2));

## RE: Array Sort order

## RE: Array Sort order

effectively I have a Multi-value Dynamic Paramenter, that I use, then select data from another table related to it Everything is perfect except the sort order !!!

## RE: Array Sort order

//-i for ascending order

...in other words, the formula will sort in ascending order as is. For descending order, remove the minus sign.

-LB

## RE: Array Sort order

this is my full code and it takes the list of multi value parameter and I need it in order

shared numbervar counter;

shared stringvar display;

for counter := 1 to count({?Pm-?Enter invoice Numbers}) do

(

display := display + totext({?Pm-?Enter invoice Numbers}[counter],0,"") + ", ";

);

stringvar Array codes :=display;

stringvar Array result;

redim preserve result[ubound(codes)];

Numbervar k;

NumberVar p;

stringvar y;

numbervar i;

for k := 1 to ubound(codes) do

(

result[k] := trim(Maximum(codes));

for p := 1 to ubound(codes) do

(

if trim(codes[p]) = result[k] then

(

codes[p] := "";

Exit For;

);

);

);

for i := 1 to ubound(result) do (

y := y + result[-i] + ", " //-1 for ascending order

);

trim(left(y,len(y)-2));

## RE: Array Sort order

shared numbervar counter;

shared stringvar display;

for counter := 1 to count({?parm}) do

(

display := display + {?parm}[counter] +

if counter <> ubound({?parm}) then ", "; //this removes the final, in display

);

WhilePrintingRecords;

stringvar Array codes := split(display,", "); //you need to split display so that it is still an array

The rest of the formula is correct. Please remove the comment at the end or change the -1 to -i, just so it is not confusing to others who might read this.

-LB