Skip to content

Commit 4e42137

Browse files
authored
Update StalinSort.java
1 parent 00a6f78 commit 4e42137

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/main/java/com/thealgorithms/sorts/StalinSort.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package com.thealgorithms.sorts;
22

3-
import java.util.Arrays;
4-
3+
/**
4+
* @author Anant Jain (https://github.com/anant-jain01)
5+
* @see https://medium.com/@kaweendra/the-ultimate-sorting-algorithm-6513d6968420
6+
*/
57
public class StalinSort implements SortAlgorithm {
8+
69
public <T extends Comparable<T>> T[] sort(T[] array) {
7-
validateInput(array);
810
int currentIndex = 0;
911

1012
for (int i = 1; i < array.length; i++) {
@@ -19,12 +21,6 @@ public <T extends Comparable<T>> T[] sort(T[] array) {
1921
return result;
2022
}
2123

22-
private void validateInput(final Comparable<?>[] array) {
23-
if (array.length == 0) {
24-
throw new IllegalArgumentException("Input array must not be empty.");
25-
}
26-
}
27-
2824
public static void main(String[] args) {
2925
Integer[] integers = {4, 23, 6, 78, 1, 54, 231, 9, 12};
3026
StalinSort stalinSort = new StalinSort();

0 commit comments

Comments
 (0)