Fixes #81911 by adding a restriction so we retrieve only publicized laye...

...rs for the virtual "others" folder.

Also, improved sorting of layers by centralizing the adding of sorting statements.