Sorting predicates in PROLOG

This is cross posted on StackOverflow


Yes.

order_by/2


Note: order_by/2 will not work with your predicates because they have different names, i.e. p1, p2, …
They need to have the same functor for order_by/2 to work, e.g.

p( 201, 5, 2 ).
p( 301, 1, 2 ).
p( 401, 1, 4 ).
p( 501, 1, 5 ).
1 Like