[JAVA-616] core-java-arrays-sorting
* Creation * Moved code from https://www.baeldung.com/java-sorting-arrays * Moved code from https://www.baeldung.com/java-check-sorted-array * Moved code from https://www.baeldung.com/java-invert-array * Moved code from https://www.baeldung.com/java-arrays-sort-vs-parallelsort
This commit is contained in:
parent
ca443a08a3
commit
29a2f0ece1
@ -13,5 +13,4 @@ This module contains articles about Java arrays
|
|||||||
- [Removing an Element from an Array in Java](https://www.baeldung.com/java-array-remove-element)
|
- [Removing an Element from an Array in Java](https://www.baeldung.com/java-array-remove-element)
|
||||||
- [Removing the First Element of an Array](https://www.baeldung.com/java-array-remove-first-element)
|
- [Removing the First Element of an Array](https://www.baeldung.com/java-array-remove-first-element)
|
||||||
- [Adding an Element to a Java Array vs an ArrayList](https://www.baeldung.com/java-add-element-to-array-vs-list)
|
- [Adding an Element to a Java Array vs an ArrayList](https://www.baeldung.com/java-add-element-to-array-vs-list)
|
||||||
- [Arrays.sort vs Arrays.parallelSort](https://www.baeldung.com/java-arrays-sort-vs-parallelsort)
|
|
||||||
- [[<-- Prev]](/core-java-modules/core-java-arrays)
|
- [[<-- Prev]](/core-java-modules/core-java-arrays)
|
||||||
|
9
core-java-modules/core-java-arrays-sorting/README.md
Normal file
9
core-java-modules/core-java-arrays-sorting/README.md
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
## Core Java Arrays - Sorting
|
||||||
|
|
||||||
|
This module contains articles about sorting arrays in Java
|
||||||
|
|
||||||
|
### Relevant Articles:
|
||||||
|
- [Sorting Arrays in Java](https://www.baeldung.com/java-sorting-arrays)
|
||||||
|
- [Checking If an Array Is Sorted in Java](https://www.baeldung.com/java-check-sorted-array)
|
||||||
|
- [How to Reverse an Array in Java](http://www.baeldung.com/java-invert-array)
|
||||||
|
- [Arrays.sort vs Arrays.parallelSort](https://www.baeldung.com/java-arrays-sort-vs-parallelsort)
|
87
core-java-modules/core-java-arrays-sorting/pom.xml
Normal file
87
core-java-modules/core-java-arrays-sorting/pom.xml
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>core-java-modules</artifactId>
|
||||||
|
<groupId>com.baeldung.core-java-modules</groupId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>core-java-arrays-sorting</artifactId>
|
||||||
|
<name>core-java-arrays-sorting</name>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<version>${shade.plugin.version}</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>shade</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<finalName>benchmarks</finalName>
|
||||||
|
<transformers>
|
||||||
|
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||||
|
<mainClass>org.openjdk.jmh.Main</mainClass>
|
||||||
|
</transformer>
|
||||||
|
</transformers>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<!-- Utilities -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
<version>${commons-lang3.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.guava</groupId>
|
||||||
|
<artifactId>guava</artifactId>
|
||||||
|
<version>${guava.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Benchmarking -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
|
<artifactId>jmh-core</artifactId>
|
||||||
|
<version>${jmh.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
|
<artifactId>jmh-generator-annprocess</artifactId>
|
||||||
|
<version>${jmh.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Testing -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.assertj</groupId>
|
||||||
|
<artifactId>assertj-core</artifactId>
|
||||||
|
<version>${assertj-core.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<shade.plugin.version>3.2.0</shade.plugin.version>
|
||||||
|
|
||||||
|
<commons-lang3.version>3.9</commons-lang3.version>
|
||||||
|
<guava.version>28.2-jre</guava.version>
|
||||||
|
|
||||||
|
<jmh.version>1.19</jmh.version>
|
||||||
|
|
||||||
|
<assertj-core.version>3.10.0</assertj-core.version>
|
||||||
|
</properties>
|
||||||
|
</project>
|
@ -1,7 +1,5 @@
|
|||||||
package com.baeldung.array;
|
package com.baeldung.array;
|
||||||
|
|
||||||
import com.baeldung.arraycopy.model.Employee;
|
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
public class SortedArrayChecker {
|
public class SortedArrayChecker {
|
@ -0,0 +1,48 @@
|
|||||||
|
package com.baeldung.sort;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class Employee implements Serializable {
|
||||||
|
private static final long serialVersionUID = -2454619097207585825L;
|
||||||
|
private int id;
|
||||||
|
private String name;
|
||||||
|
private int age;
|
||||||
|
|
||||||
|
public Employee() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Employee(int id, String name) {
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Employee(int id, String name, int age) {
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
this.age = age;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAge() {
|
||||||
|
return age;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAge(int age) {
|
||||||
|
this.age = age;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
package com.baeldung.array;
|
package com.baeldung.array;
|
||||||
|
|
||||||
import com.baeldung.arraycopy.model.Employee;
|
import com.baeldung.sort.Employee;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
@ -1,6 +1,5 @@
|
|||||||
package com.baeldung.sort;
|
package com.baeldung.sort;
|
||||||
|
|
||||||
import com.baeldung.arraycopy.model.Employee;
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@ -86,5 +85,4 @@ public class ArraySortUnitTest {
|
|||||||
|
|
||||||
assertArrayEquals(new Employee[]{david, john, mary}, employees);
|
assertArrayEquals(new Employee[]{david, john, mary}, employees);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -10,7 +10,4 @@ This module contains articles about Java arrays
|
|||||||
- [Multi-Dimensional Arrays In Java](https://www.baeldung.com/java-jagged-arrays)
|
- [Multi-Dimensional Arrays In Java](https://www.baeldung.com/java-jagged-arrays)
|
||||||
- [Find Sum and Average in a Java Array](https://www.baeldung.com/java-array-sum-average)
|
- [Find Sum and Average in a Java Array](https://www.baeldung.com/java-array-sum-average)
|
||||||
- [Arrays in Java: A Reference Guide](https://www.baeldung.com/java-arrays-guide)
|
- [Arrays in Java: A Reference Guide](https://www.baeldung.com/java-arrays-guide)
|
||||||
- [How to Reverse an Array in Java](http://www.baeldung.com/java-invert-array)
|
|
||||||
- [Sorting Arrays in Java](https://www.baeldung.com/java-sorting-arrays)
|
|
||||||
- [Checking If an Array Is Sorted in Java](https://www.baeldung.com/java-check-sorted-array)
|
|
||||||
- [[More -->]](/core-java-modules/core-java-arrays-2)
|
- [[More -->]](/core-java-modules/core-java-arrays-2)
|
||||||
|
@ -122,6 +122,7 @@
|
|||||||
|
|
||||||
<!-- <module>multimodulemavenproject</module> --> <!-- We haven't upgraded to java 9. Fixing in BAEL-10841 -->
|
<!-- <module>multimodulemavenproject</module> --> <!-- We haven't upgraded to java 9. Fixing in BAEL-10841 -->
|
||||||
<module>pre-jpms</module>
|
<module>pre-jpms</module>
|
||||||
|
<module>core-java-arrays-sorting</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user