sort by dbname before outputting

Change-Id: I57b69c9d577cf84934eb37667be33fb50564bed0