Skip to content

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.

1 participant