When sorting in the sidebar, only files are sorted, but the folders that contain them are not.
Anyone would expect that when sorting a tree structure all nodes are sorted, not just leaf nodes.
here are two screenshots of my vault with opposite sorts set – name A-Z, and name Z-A. As you can see, the folders appear in the same exact order, it’s just the files within them that change sort order.