Skip to content

feat: argument 'asc' or 'desc' missing in method sort() in ibis/expr/types/arrays.py #10442

Open
@mercelino

Description

@mercelino

Is your feature request related to a problem?

the method sort() does not have an option to sort in a descending way, it sorts only in an ascending way by default
Although the option to sort in a descending way does exist in DuckDB as well: https://duckdb.org/docs/sql/functions/list#sorting-lists

What is the motivation behind your request?

I am converting from writing raw SQL in python using string for DuckDB backend to using Ibis in order to increase readability and having the ability to switch to other backends.

Describe the solution you'd like

i would be able to do table.column.mode()
Example:
t = ibis.memtable(
... {
... "id": range(3),
... "arr": [
... [1, 2, 3, 3],
... [1, 1, 2, 2, 3, 4],
... [1, 1, 2 ,3]
... ],
... }
... )

The output of t.arr.sort('asc') would be the same as the output of the current method, so the 'asc' can be the argument by default.

The output of t.arr.sort('desc') would be a column of the following elements [[3, 3, 2, 1], [4, 3, 2, 2, 1, 1], [3, 2, 1, 1]]

What version of ibis are you running?

9.5.0

What backend(s) are you using, if any?

DuckDB

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureFeatures or general enhancements

    Type

    No type

    Projects

    • Status

      backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions