{"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":1466,"sourceCode":"                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-map\")]\n            (Map(_), Map(_)) => {\n                unimplemented!(\"ordering for Map 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":1448,"sourceCodeEnd":1484,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-core/src/datatypes/any_value.rs#L1448-L1484","documentation":"AnyValue::partial_cmp panics for Array (fixed-size list) scalar pairs because no ordering is defined for fixed-size list values (feature 'dtype-array'). Comparison-based operations on Array columns therefore abort instead of sorting.","triggerScenarios":"Sorting by, or comparing scalars of, a column with dtype Array(...) (fixed-size list), e.g. df.sort on the Array column or min/max over it.","commonSituations":"Working with Arrow fixed-size-list / numpy-like fixed-shape data (often via the dtype-array feature) and then attempting to sort or take min/max on that column.","solutions":["Cast the Array column to List or extract elements: pl.col('a').arr.get(0) as sort key","Explode the array column before ordering","Sort by an aggregate of the array (e.g. .arr.sum(), .arr.max())","Re-enable only when an upstream ordering implementation exists"],"exampleFix":"// before\ndf.sort('vec')  # vec: Array(f64, 3) -> panics\n// after\ndf.sort(pl.col('vec').arr.get(0))","handlingStrategy":"validation","validationCode":"if isinstance(df.schema[col], pl.Array):\n    key = pl.col(col).arr.get(0)  # choose an element/aggregate as key","typeGuard":"def is_fixed_array(dtype) -> bool:\n    return isinstance(dtype, pl.Array)","tryCatchPattern":null,"preventionTips":["Avoid sorting Array columns directly; sort by an element or aggregate","Explode arrays before ranking","Remember 'dtype-array' feature data often comes from Arrow fixed-size lists"],"tags":["polars","rust","sorting","array-dtype"],"backgroundTag":"unsupported-operation","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}