Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support key param for sortBy and sortByDescending #33

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

couzic
Copy link
Contributor

@couzic couzic commented Mar 29, 2022

Currently, it is possible to sort using the key of an item, but only through the Comparator and ComparatorFactory interfaces, for example:

.sorted(it => it.compareBy("x"))

.sorted(it => it.compareByDescending("x"))

.thenBy("y"))

.thenByDescending("x"))

The goal of this PR is to enable sorting by key directly on the Sequence type, like:

        sequenceOf(a4, a1, a3, a23)
            .sortedBy("a")
        sequenceOf(a4, a1, a3, a23)
            .sortedByDescending("a")

Also, this PR exports the Comparator and ComparatorFactory types, so that they are added to the docs (which suppresses a couple warnings when generating them)

@couzic
Copy link
Contributor Author

couzic commented Mar 29, 2022

Hello @winterbe,
I've been willing to do this for a long time. With this PR, the sorting functions should finally be consistent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant