Hi!
Sorry for the late reply.
This depends on the implementation.
OpenNARS: create a class which extends Operator and implements the execute method, there the sorting needs to be done and a feedback event as you suggested with the sorted version of the product can be invoked. Register the op with nar.addOperation(new Sort("^sort"));
ONA: if Python wrapper is used: NAR.AddInput("*setopname 1 ^sort").
Now when NAR.AddInput is called, it will return a dict, with key "executions". Check for a call of ^sort and the arguments, if present do the sorting in Python and add the feedback event with another NAR.AddInput call such as NAR.AddInput("<({SELF * (1 * 2)) --> ^sort>.") Little detail: n-ary products need to be 2-ary nested products instead, e.g. (1 * (2 * 3)).
C/C++:
NAR_AddOperation(Narsese_AtomicTerm("^sort"), SortFunction);
whereby SortFunction is function pointer to a function with void return value and Term (the args product) as input.
Best regards,
Patrick