Looking at this some more, this query only addresses top categories, ordering first by sort order and then by name, so it should work simply as described. If you don't need the cat-tabs to display differently from the categories sidebox, just switching the order should work without any testing needed.