Skip to content

Add column selector overload to GroupBy.sortByKey #1523

Description

@AndreiKingsley

Now you can't specify key columns for sorting in sortByKey (all columns are used with the same order). No implementation is needed, need only to add an overload with column selector.

Problem

GroupBy.sortByKey currently sorts by all key columns with the same order.

It is not possible to specify which key columns should be used for sorting.

This limits flexibility when working with grouped data.

Expected

Allow selecting specific key columns for sorting.

Proposed solution

Add an overload of sortByKey that accepts a column selector.

Example:

groupBy { a and b }.sortByKey { a }

Acceptance criteria

  • New overload of sortByKey accepts column selector
  • Users can specify subset of key columns
  • Existing behavior (sorting by all keys) remains unchanged
  • Add tests for:
    • sorting by all keys (current behavior)
    • sorting by subset of keys
  • Add minimal documentation/example

Motivation

Sorting grouped data is a common operation.

Lack of column selection makes API less flexible compared to other DSL operations, which already support selectors.

This is a small but important consistency improvement before 1.0.

Activity

  1. added
    enhancement
    good first issue
    on Oct 29, 2025
  2. Jolanrensen commented on Oct 29, 2025

    @Jolanrensen
    Collaborator

    specifically, it needs a column selector for the GroupBy.keys columns. At the moment, this has the same type as the original dataframe, meaning it has accessors for columns that may not exist in the keys.

    With the compiler plugin enabled, this is no issue.

    Actually, come to think of it, you can already sort by specific key columns:

    df.groupBy { a and b }.sortBy { a }

    sortByKey() is simply a shortcut to sort for all key columns

  3. added this to the Backlog milestone on Dec 5, 2025
  4. added a commit that references this issue on Mar 25, 2026
    6831cc1
  5. removed
    good first issue
    on Mar 26, 2026
  6. modified the milestones: Backlog, 1.0.0-Backlog on Apr 8, 2026
  7. changed the title [-]Add column selector for `GroupBy.sortByKey`[/-] [+]Add column selector overload to `GroupBy.sortByKey`[/+] on Apr 27, 2026
  8. modified the milestones: Post-RC, 1.0 on Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions