Use the container’s OnAdd and a user Date-type field (Date is a date and time), let’s call it ‘SortDate’ date.
$SortDate = date("now");
Set the container sort order on SortDate, here shown in the Inspector:
This sorts oldest first - if you want the most recent to sort first tick the ‘reverse’ box (which sets $SortBackward).
Result, when implemented (column view just for screengrab purposes):
If you want to do this for lots of containers, make a container with the above settings, move it to your Prototypes container (ensuring it becomes a prototype) . Then, whenever you need a new ‘sorted’ container, you can use the prototype.
Or, if you need to use prototypes for other purposes, this stamp will set up the container settings needed:
$OnAdd = '$SortDate = date("now");';
$Sort = "SortDate";
// uncomment next line for newest first
//$SortBackward = true;
Note the last option (re time=-based sort order) is commented out—see discussion of this point further above.
Here is a TBX showing all the above, including the stamp: sorted-container-test.tbx (107.4 KB)