list_sort

Sorts a list.

Available in:

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

Syntax

void list_sort(list-name,col[,col,...],direction)
list           list-name
int            col,direction

Description

Sorts a list; leaves current list item unchanged.
list-name specifies the list to sort.

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 xx;
 int i;
 xx = list_open("20 16 10", 1000, "Improvements");
 list_mod(xx, 1, 5, 10, 15);
 list_mod(xx, 1, 15, 10, 5);

 printf("col 2, asc\n");
 list_sort(xx, 2, 1);
 list_seek(xx,0);
 for (i=list_rows(xx);i;i--) printf(list_read(xx,2));

 printf("col 0, des\n");
 list_sort(xx, 0, 0);
 list_seek(xx,0);
 for (i=list_rows(xx);i;i--) printf(list_read(xx,0));
 list_close(xx);
}