orderby
It sorts the output over some positions of the atom.
The syntax is the following:
@post("atomName", "orderby(p1,..., pn)").
where atomName
is the atom to be sorted, p1, …, pn
are integers denoting a valid position in atomName (starting from 1). The sorting is orderly applied on the various positions. A position can be prefixed with the minus sign (-) to denote descending sorting.
For the various data types the usual order relations are assumed (to be extended).
Example 39
t(1,"b",5).
t(1,"a",1).
t(1,"c",1).
p(X,Y,Z) :- t(X,Y,Z).
@output("p").
@post("p","orderby(3,-2)").
We order by the third position (ascending) and, for the same value of the third position, by descending values of the second position.
The expected result is: p(1,"c",1). p(1,"a",1). p(1,"b",5).