Use convenience function in Numbers to group instance IDs.

Reviewed at https://reviews.apache.org/r/24823/