Skip to content

Commit

Permalink
Add a semver based sort for major channels
Browse files Browse the repository at this point in the history
  • Loading branch information
udda1996 committed Nov 20, 2023
1 parent f5acf48 commit 3c0eafa
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/main/java/org/ballerinalang/command/cmd/ListCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,13 @@ private static void listDistributions(PrintStream outStream, boolean allFlag, bo
else {
outStream.println("\n" + channel.getName() + "\n");
List<Distribution> channelDistList = channel.getDistributions();
if (channel.getName().equals("Swan Lake channel")) {
channelDistList.sort(Comparator.comparing(Distribution::getVersion));
if (channel.getName().equals("Swan Lake channel") || channel.getName().equals("1.* channel")) {
Comparator<Distribution> semverComparator = Comparator
.comparingInt((Distribution distribution) -> Integer.parseInt(distribution.getVersion().split("\\.")[0]))
.thenComparingInt((Distribution distribution) -> Integer.parseInt(distribution.getVersion().split("\\.")[1]))
.thenComparingInt((Distribution distribution) -> Integer.parseInt(distribution.getVersion().split("\\.")[2]));

channelDistList.sort(semverComparator);
Collections.reverse(channelDistList);
}
if (!allFlag){
Expand Down

0 comments on commit 3c0eafa

Please sign in to comment.