list_sort2

Sorts a list using a user trigger.

Available in:

Apps (win) Apps (char) Reportwriter RPC Standalone PL
X X X X X

Syntax

void list_sort2(list-name,cmp,col[,col,...],direction)
list            list-name
trigger         cmp;
int             col,direction

Description

Sorts a list; leaves current list item unchanged. The column comparisons are done by the user trigger. The trigger receives the column data as sets of parameters (parm.n or parm[n]): all comparison columns of first row, then those of the second row. The user trigger must return (-1) if the first row is smaller than the second row, 0 if they are equal, or 1 if the first row is greater than the second row.
list-name specifies the list to sort.

cmp specifies the user trigger to receive the column data to compare.

col specifies the column on which to sort. If multiple columns are specified, the sort is performed on all the columns in the order specified.

direction specifies sort order:
  • 1 --- Ascending order.
  • 0 --- Descending order.

Example

Sorts a given list by the specified column and order.
{
list    LL;
trigger cmp = 
  {
  if (parm.0 > parm.2) return(1);
  if (parm.0 < parm.2) return(-1);

  if (parm.1 > parm.3) return(1);
  if (parm.1 < parm.3) return(-1);

  return(0);
  };

LL = list_open("x zip.xml",99999);

list_sort2(LL,cmp,0,1,true);
}