baml._is_primitive_array

Whether `arr` is a homogeneous primitive array (`int`/`bigint`/`string`/ `float`) that the native `_rust_sort` fast path can natural-sort, decided by the first element's runtime type tag (a `T[]`'s homogeneity plus the `T extends baml.ops.Compare` bound at the call sites guarantee the first element speaks for the whole array). Empty arrays return `true` — the native sort is a no-op on them. Internal: this is `Sortable.sort`'s dispatch guard. It tests runtime *values* rather than type arguments because a BAML-level `is`-test on a `T`-typed value constant-folds to false, and frame type args are not reliable across every call path into a blanket impl.

Reference version

Signature

function baml._is_primitive_array<T extends baml.ops.Compare>(arr: T[]) -> bool throws never

Whether arr is a homogeneous primitive array (int/bigint/string/ float) that the native _rust_sort fast path can natural-sort, decided by the first element's runtime type tag (a T[]'s homogeneity plus the T extends baml.ops.Compare bound at the call sites guarantee the first element speaks for the whole array). Empty arrays return true — the native sort is a no-op on them. Internal: this is Sortable.sort's dispatch guard. It tests runtime values rather than type arguments because a BAML-level is-test on a T-typed value constant-folds to false, and frame type args are not reliable across every call path into a blanket impl.

Source:<builtin>/baml/sortable.bamlbytes 2609–2719