{"record":{"id":"8cec531b94f1bbb6","repo":"pola-rs/polars","slug":"ordering-for-array-dtype-is-not-supported","errorCode":null,"errorMessage":"ordering for Array dtype is not supported","messagePattern":"ordering for Array dtype is not supported","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-core/src/datatypes/any_value.rs","lineNumber":1445,"sourceCode":"            #[cfg(feature = \"dtype-categorical\")]\n            (Categorical(l_cat, l_map), Categorical(r_cat, r_map)) => unsafe {\n                let l_str = l_map.cat_to_str_unchecked(*l_cat);\n                let r_str = r_map.cat_to_str_unchecked(*r_cat);\n                l_str.partial_cmp(r_str)\n            },\n            #[cfg(feature = \"dtype-categorical\")]\n            (Enum(l_cat, l_map), Enum(r_cat, r_map)) => {\n                if !Arc::ptr_eq(l_map, r_map) {\n                    unimplemented!(\"can't order enums from different FrozenCategories\")\n                }\n                l_cat.partial_cmp(r_cat)\n            },\n            (List(_), List(_)) => {\n                unimplemented!(\"ordering for List dtype is not supported\")\n            },\n            #[cfg(feature = \"dtype-array\")]\n            (Array(..), Array(..)) => {\n                unimplemented!(\"ordering for Array dtype is not supported\")\n            },\n            #[cfg(feature = \"object\")]\n            (Object(_), Object(_)) => {\n                unimplemented!(\"ordering for Object dtype is not supported\")\n            },\n            #[cfg(feature = \"dtype-struct\")]\n            (StructOwned(_), StructOwned(_))\n            | (StructOwned(_), Struct(..))\n            | (Struct(..), StructOwned(_))\n            | (Struct(..), Struct(..)) => {\n                unimplemented!(\"ordering for Struct dtype is not supported\")\n            },\n            #[cfg(feature = \"dtype-decimal\")]\n            (Decimal(lv, _lp, ls), Decimal(rv, _rp, rs)) => Some(dec128_cmp(*lv, *ls, *rv, *rs)),\n\n            (_, _) => {\n                unimplemented!(\n                    \"scalar ordering for mixed dtypes {self:?} and {other:?} is not supported\"","sourceCodeStart":1427,"sourceCodeEnd":1463,"githubUrl":"https://github.com/pola-rs/polars/blob/df599052daf96e7a9cc30a3b0c6bd25d6947e3c0/crates/polars-core/src/datatypes/any_value.rs#L1427-L1463","documentation":"AnyValue::partial_cmp rejects ordering between Array (fixed-size list) scalars. Like List, there is no scalar-level ordering kernel for nested array values, so the arm panics with unimplemented!().","triggerScenarios":"Comparing two Array AnyValues with <, >, min, max, or sorting scalars extracted from a pl.Array column: df[\"arr\"].get(0) < df[\"arr\"].get(1).","commonSituations":"Fixed-width embedding/vector columns where user code tries to rank or compare individual vectors cell by cell.","solutions":["Extract an element or reduce to a scalar key first: arr.get(0), arr.sum(), or dot products via expressions, then compare","Use Array-level expressions (polars supports element-wise ops on pl.Array) instead of scalar comparisons","Cast the column to List and use list expressions if you need list-style ordering helpers"],"exampleFix":"# before\nsmaller = df[\"vec\"].get(0) < df[\"vec\"].get(1)  # panics\n\n# after\nsmaller = df[\"vec\"].arr.get(0).get(0) < df[\"vec\"].arr.get(0).get(1)","handlingStrategy":"type-guard","validationCode":"def orderable_dtype(dt) -> bool:\n    return not isinstance(dt, (pl.List, pl.Array, pl.Struct)) and dt != pl.Object","typeGuard":"def orderable_dtype(dt) -> bool:\n    return not isinstance(dt, (pl.List, pl.Array, pl.Struct)) and dt != pl.Object","tryCatchPattern":null,"preventionTips":["For pl.Array vectors, order by an extracted component or a reduction (sum, norm)","Use arr namespace expressions instead of comparing Array cells as scalars"],"tags":["rust","polars","panic","unimplemented","any-value","array","fixed-size-list","ordering"],"backgroundTag":null,"analyzedSha":"df599052daf96e7a9cc30a3b0c6bd25d6947e3c0","analyzedAt":"2026-08-16T12:10:03.978Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}