I think I wrote the rest of index_secondary_by_primary. Let's test it.
Adding a case for integers (which don't support nan :( )