Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to sort it twice. The first
.sorted
call should be enough, although it may need to be reversed. Otherwise we can remove it and only keep thesortBy(_._1).reverse
. But I think I would prefer to keep the first one.EDIT: I am wrong here, the first
.sorted
is useless because it is followed by.groupBy
which does not preserve the order.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct me if im wrong.
First
.sorted
will sort the binary versions and then thesortBy(_._1).reverse
will sort the grouped platforms. So output of this approach will be binary versions are in sorted order and the platforms will also be sorted that way Scala Native 0.5 will always appear before Scala Native 0.4.Alternative to this approach will be sorting the grouped platforms based on the max version in each platform group and then sort the binary versions to show the latest first. It can be done by something like this-
allBinaryVersions.groupBy(_.platform).toSeq .sortBy { binaryVersions.map(_.version).max }
Output of this approach will be binary versions are in sorted order and the platforms will be sorted based on which platform has latest/max binary version. So Scala Native 0.5 will be over Scala Native 0.4.
And also we dont need to sort it twice using alternate approach.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The binary versions is composed of the platform and the language. So sorting the binary version should also sort the platforms and we should not need to sort them again. But then the
.groupBy
creates aMap
which does not preserve the order. So I think the solution here is to remove the firstsorted
:There already is an
Ordering[Platform]
defined as :scaladex/modules/core/shared/src/main/scala/scaladex/core/model/Platform.scala
Lines 81 to 87 in a306d3c
We should better use it than redefining a custom one here.