```{index} single: uniqind; PDL::Primitive function ``` ```{index} single: PDL::Primitive::uniqind; Perl function ``` # uniqind `uniqind($pdl)` — return flat indices of unique elements. Mirrors `PDL::uniqind` from `Primitive.pm:727-756`. Semantics: 1. Flatten input. 2. NaN indices go at the end of the result (NaN is never equal to itself). 3. Among non-NaN values: sort by value (stable → first-occurrence wins), find positions where sorted values change (rotate-minus-one diff), map those back through the sort permutation to original indices. 4. Empty input → returns input unchanged.