Sort tables before returning them.

This fixes unsorted table lists in the various bake related tasks.

Fixes #2386
Fix failing tests when Console group was run in isolation.
Remove pointless array cast.