Firefox 3
Quick navigation:

ptb_sort

Sorts $database on multiple columns.

Syntax

$var = ptb_sort($database, $sort);

Syntax description

$database
variable containing connected database
$sort
how records should be sorted: set of pairs: fieldname and ASC/DESC, separated with commas (see sample)

Return

This function returns array.

Sample(s)

$myDatabase = ptb_sort($myDatabase, 'name ASC, birth DESC');

Limitation

You can't sort on link (@fieldname) nor multi (%fieldname) field (but you can on linked field).

Tips

If no last sorting sequence (i.e. ASC or DESC) is given, ASC is used:

$myDatabase = ptb_sort($myDatabase, 'name ASC, birth');

is equal to:

$myDatabase = ptb_sort($myDatabase, 'name ASC, birth ASC');

If you select any records from your database, you can do sorting in one go with ptb_select. In fact, ptb_select simply uses ptb_sort internally.