We always sort folders, not just when we want the unassigned layers virtual folder.
Fixes #85815 by checking if the layer is enabled before adding it to the results. Also, some code style improvements have been applied.
Merge pull request #106 from luisromangz/8.5-SNAPSHOT-85815

Fix for #85815: unhabilited folders no longer are shown in the composer