Related categories order posts by category

You have a couple hurdles to handle …

1) You can have multiple Category codes for each post, so they are not normal query variables (not really a hurdle – but you may get repeat occurrances of the same post under multiple categories).

2) Category titles are 1 linkage ‘further’ away (in terms of SQL queries) than the category code. i.e. the post is connected to the Category code(s), then those codes are connected to the code titles. This is more of a challenge.

THIS POST shows a similar issue with a solution of getting all the categories, then running a filtered query for each category, and displaying the post list for that category. Perhaps that is close enough to what you are looking for?