Skip to content

Commit 98fa030

Browse files
authored
Merge branch 'eugenp:master' into master
2 parents e4e5d98 + 2248da8 commit 98fa030

File tree

2,595 files changed

+38404
-5017
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,595 files changed

+38404
-5017
lines changed

README.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,21 @@ We also have a parents profile to build only parent modules.
4444

4545
Therefore, we have a total of 9 profiles:
4646

47-
| Profile | Includes | Type of test enabled |
48-
|--------------------|-----------------------------|------------------------------|
49-
| default | JDK21 projects | *UnitTest |
50-
| integration | JDK21 projects | *IntegrationTest |
51-
| default-jdk17 | JDK17 projects | *UnitTest |
52-
| integration-jdk17 | JDK17 projects | *IntegrationTest |
53-
| profile-jdk22 | JDK22 projects | *UnitTest & *IntegrationTest |
54-
| profile-jdk23 | JDK23 projects | *UnitTest & *IntegrationTest |
55-
| default-heavy | Heavy/long running projects | *UnitTest |
56-
| integration-heavy | Heavy/long running projects | *IntegrationTest |
57-
| default-jdk8 | JDK8 projects | *UnitTest |
58-
| integration-jdk8 | JDK8 projects | *IntegrationTest |
59-
| parents | Set of parent modules | None |
47+
| Profile | Includes | Type of test enabled |
48+
|-------------------|-----------------------------|----------------------|
49+
| default | JDK21 projects | *UnitTest |
50+
| integration | JDK21 projects | *IntegrationTest |
51+
| default-jdk17 | JDK17 projects | *UnitTest |
52+
| integration-jdk17 | JDK17 projects | *IntegrationTest |
53+
| default-jdk22 | JDK22 projects | *UnitTest |
54+
| integration-jdk22 | JDK22 projects | *IntegrationTest |
55+
| default-jdk23 | JDK23 projects | *UnitTest |
56+
| integration-jdk23 | JDK23 projects | *IntegrationTest |
57+
| default-heavy | Heavy/long running projects | *UnitTest |
58+
| integration-heavy | Heavy/long running projects | *IntegrationTest |
59+
| default-jdk8 | JDK8 projects | *UnitTest |
60+
| integration-jdk8 | JDK8 projects | *IntegrationTest |
61+
| parents | Set of parent modules | None |
6062

6163
Building the project
6264
====================

akka-modules/akka-http/pom.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<dependency>
2222
<groupId>com.typesafe.akka</groupId>
2323
<artifactId>akka-stream_${scala.version}</artifactId>
24-
<version>${akka.stream.version}</version>
24+
<version>${akkastreams.version}</version>
2525
</dependency>
2626
<dependency>
2727
<groupId>com.typesafe.akka</groupId>
@@ -38,7 +38,6 @@
3838

3939
<properties>
4040
<akka.http.version>10.0.11</akka.http.version>
41-
<akka.stream.version>2.5.11</akka.stream.version>
4241
</properties>
4342

4443
</project>

akka-modules/akka-streams/pom.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,4 @@
2525
</dependency>
2626
</dependencies>
2727

28-
<properties>
29-
<akkastreams.version>2.5.2</akkastreams.version>
30-
</properties>
31-
3228
</project>

akka-modules/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
<properties>
3535
<scala.version>2.12</scala.version>
36+
<akkastreams.version>2.5.11</akkastreams.version>
3637
</properties>
3738

3839
</project>

algorithms-modules/algorithms-miscellaneous-1/pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@
6868
</reporting>
6969

7070
<properties>
71-
<combinatoricslib3.version>3.3.0</combinatoricslib3.version>
7271
<xml-bind-api.version>4.0.0</xml-bind-api.version>
7372
</properties>
7473

algorithms-modules/algorithms-miscellaneous-4/pom.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,4 @@
3737
</dependency>
3838
</dependencies>
3939

40-
<properties>
41-
<combinatoricslib3.version>3.3.3</combinatoricslib3.version>
42-
</properties>
43-
4440
</project>

algorithms-modules/algorithms-miscellaneous-5/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
<configuration>
4848
<source>17</source>
4949
<target>17</target>
50+
<release>17</release>
5051
</configuration>
5152
</plugin>
5253
</plugins>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.baeldung.algorithms.stringsort;
2+
3+
import java.util.Arrays;
4+
import java.util.Comparator;
5+
6+
public class AlphanumericSort {
7+
8+
public static String lexicographicSort(String input) {
9+
char[] stringChars = input.toCharArray();
10+
Arrays.sort(stringChars);
11+
return new String(stringChars);
12+
}
13+
14+
public static String[] naturalAlphanumericSort(String[] arrayToSort) {
15+
Arrays.sort(arrayToSort, new Comparator<String>() {
16+
@Override
17+
public int compare(String s1, String s2) {
18+
return extractInt(s1) - extractInt(s2);
19+
}
20+
21+
private int extractInt(String str) {
22+
String num = str.replaceAll("\\D+", "");
23+
return num.isEmpty() ? 0 : Integer.parseInt(num);
24+
}
25+
});
26+
return arrayToSort;
27+
}
28+
29+
public static String[] naturalAlphanumericCaseInsensitiveSort(String[] arrayToSort) {
30+
Arrays.sort(arrayToSort, Comparator.comparing((String s) -> s.replaceAll("\\d", "").toLowerCase())
31+
.thenComparingInt(s -> {
32+
String num = s.replaceAll("\\D+", "");
33+
return num.isEmpty() ? 0 : Integer.parseInt(num);
34+
})
35+
.thenComparing(Comparator.naturalOrder()));
36+
return arrayToSort;
37+
}
38+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.baeldung.algorithms.stringsort;
2+
3+
import org.junit.jupiter.api.Test;
4+
5+
import java.util.Arrays;
6+
7+
import static org.assertj.core.api.Assertions.assertThat;
8+
9+
class AlphanumericSortUnitTest {
10+
11+
@Test
12+
void givenAlphanumericString_whenLexicographicSort_thenSortLettersFirst() {
13+
String stringToSort = "C4B3A21";
14+
String sorted = AlphanumericSort.lexicographicSort(stringToSort);
15+
assertThat(sorted).isEqualTo("1234ABC");
16+
}
17+
18+
@Test
19+
void givenAlphanumericArrayOfStrings_whenAlphanumericSort_thenSortNaturalOrder() {
20+
String[] arrayToSort = {"file2", "file10", "file0", "file1", "file20"};
21+
String[] sorted = AlphanumericSort.naturalAlphanumericSort(arrayToSort);
22+
assertThat(Arrays.toString(sorted)).isEqualTo("[file0, file1, file2, file10, file20]");
23+
}
24+
25+
@Test
26+
void givenAlphanumericArrayOfStrings_whenAlphanumericCaseInsensitveSort_thenSortNaturalOrder() {
27+
String[] arrayToSort = {"a2", "A10", "b1", "B3", "A2"};
28+
String[] sorted = AlphanumericSort.naturalAlphanumericCaseInsensitiveSort(arrayToSort);
29+
assertThat(Arrays.toString(sorted)).isEqualTo("[A2, a2, A10, b1, B3]");
30+
}
31+
}

algorithms-modules/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
<commons-math3.version>3.6.1</commons-math3.version>
3838
<cobertura.plugin.version>2.7</cobertura.plugin.version>
3939
<tradukisto.version>1.0.1</tradukisto.version>
40+
<combinatoricslib3.version>3.3.3</combinatoricslib3.version>
4041
</properties>
4142

4243
</project>

0 commit comments

Comments
 (0)