When layer sorting panel and view entities, I find that I can put view entities on top of panels only for a single frame. After that, the panel is displayed over the view entity.
So, to keep the view entity on top of the panel, I can layer_sort every frame, though to optimize my code I would want to run layer_sort only when the order of the layers should change.
layer_sort seems to create an exception to the usual way that layers are sorted. If you keep with the current layer system (panels are always on top of view entities in positive number ranges), you should probably remove this one-frame exception.
Better would be to have panels, texts, and view entities sort strictly by number and only default to panels on top of views when they have the same layer number. --- Really, why not allow view entities to display on top of panels?
The manual hints at the current behavior in only one place: view.layer states that "Panels and texts will always be displayed over all views independently of their LAYER values." It appears that view entities are included as views for purposes of this behavior, and it might be helpful to see this in the other places where layer and layer_sort are described.