Don't order empty tables

Fixes #2239