pola-rs/polars · error
ordering for Array dtype is not supported
Error message
ordering for Array dtype is not supported
What it means
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.
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
Example fix
// before
df.sort('vec') # vec: Array(f64, 3) -> panics
// after
df.sort(pl.col('vec').arr.get(0)) Defensive patterns
Strategy: validation
Validate before calling
if isinstance(df.schema[col], pl.Array):
key = pl.col(col).arr.get(0) # choose an element/aggregate as key Type guard
def is_fixed_array(dtype) -> bool:
return isinstance(dtype, pl.Array) Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- ordering for List dtype is not supported
- ordering for Map dtype is not supported
- ordering for Object dtype is not supported
- ordering for Struct dtype is not supported
- {0}
AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18).
Data as JSON: /api/errors/8cec531b94f1bbb6.
Report an issue: GitHub.
Appendix: source
Thrown at crates/polars-core/src/datatypes/any_value.rs:1466
l_str.partial_cmp(r_str)
},
#[cfg(feature = "dtype-categorical")]
(Enum(l_cat, l_map), Enum(r_cat, r_map)) => {
if !Arc::ptr_eq(l_map, r_map) {
unimplemented!("can't order enums from different FrozenCategories")
}
l_cat.partial_cmp(r_cat)
},
(List(_), List(_)) => {
unimplemented!("ordering for List dtype is not supported")
},
#[cfg(feature = "dtype-map")]
(Map(_), Map(_)) => {
unimplemented!("ordering for Map dtype is not supported")
},
#[cfg(feature = "dtype-array")]
(Array(..), Array(..)) => {
unimplemented!("ordering for Array dtype is not supported")
},
#[cfg(feature = "object")]
(Object(_), Object(_)) => {
unimplemented!("ordering for Object dtype is not supported")
},
#[cfg(feature = "dtype-struct")]
(StructOwned(_), StructOwned(_))
| (StructOwned(_), Struct(..))
| (Struct(..), StructOwned(_))
| (Struct(..), Struct(..)) => {
unimplemented!("ordering for Struct dtype is not supported")
},
#[cfg(feature = "dtype-decimal")]
(Decimal(lv, _lp, ls), Decimal(rv, _rp, rs)) => Some(dec128_cmp(*lv, *ls, *rv, *rs)),
(_, _) => {
unimplemented!(
"scalar ordering for mixed dtypes {self:?} and {other:?} is not supported"View on GitHub (pinned to fe841f959e)