Add support for NaN or undefined group keys.

Previously, a group key of NaN or undefined would result in that value
going to the last non-NaN group.