Sort the external refs table by database type