Force record ordering reset

Hi. In the case of regular models and the sortable trait, I have managed to hook to the beforeCreate event to force the new record to be placed on top (first) instead of at the bottom as default, using this:

public function beforeCreate()
        $this->sort_order = 0;

And it “works”. BUT if you create more than one record without making any reordering, the newest record is placed AFTER the previous one, because logically both have sort_oder = 0. If you reorder any record, I can see that the whole values of sort_order are somehow recalculated (“reset?”). So I’d like to know if I can manually call that “recaculation” process in the event I’m hooking to (or maybe that in the afterCreate). That would for sure solve my problem. But I really don’t know how to call that process.

Can somebody help me with this?

The nested tree trait has resetTreeNesting and resetTreeOrphans. We may need to add an equivalent function to the SimpleTree trait.

@daft do you know if this addition is planned?