diff --git a/ibis/backends/polars/compiler.py b/ibis/backends/polars/compiler.py index c9334577a27fd..ce8de0cce67f6 100644 --- a/ibis/backends/polars/compiler.py +++ b/ibis/backends/polars/compiler.py @@ -227,10 +227,14 @@ def sort(op, **kw): by = list(newcols.keys()) descending = [key.descending for key in op.keys] + # NOT SURE IF THIS IS THE RIGHT THING TO DO + nulls_first = all(key.nulls_first for key in op.keys) try: - lf = lf.sort(by, descending=descending, nulls_last=True) + lf = lf.sort(by, descending=descending, nulls_last=not nulls_first) except TypeError: # pragma: no cover - lf = lf.sort(by, reverse=descending, nulls_last=True) # pragma: no cover + lf = lf.sort( + by, reverse=descending, nulls_last=not nulls_first + ) # pragma: no cover #THIS DOESN'T WORK reverse doesn't exists (?) return lf.drop(*by)