Previous topic  Top  Next topic  Print this Topic
 

Sorting Query Results: sort

 

This query option allows sorting of the result of the query.

Example:

@{q1, options[sort(asc(?X),desc(?Y))]} ?- ?X::?Y.

This example will sort the query results in the ascending order of bindings for ?X and in descending order of bindings for ?Y. It is also possible to write

@{q1, options[sort(?X,desc(?Y))]} ?- ?X::?Y.

The ?X will be be interpreted as asc(?X), so that you can just leave out the asc(..).