In my manual under "layer_sort" - or more exactly under "CScript/Engine functions/Panels, Texts, Views/layer_sort".

I don't see the problem with texts:

text bla {...}
layer_sort(bla, 9999);