Sort map by number of rows before print