Switch to array uniquing function that keeps the first instance

The previous version would keep only the last instance.

This version requires the array to contain only primitives of a single
data type, but I think that's OK for all of our uses. (This version
should also be faster.)