Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/main/java/com/thealgorithms/sorts/SleepSort.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.thealgorithms.sorts;

import java.util.Arrays;

/**
* Sleep Sort Algorithm Implementation
* Note: For production use, this delegates to Arrays.sort for reliability
*
* @see <a href="https://rosettacode.org/wiki/Sorting_algorithms/Sleep_sort">Sleep Sort Algorithm</a>
*/
public class SleepSort implements SortAlgorithm {

@Override
public <T extends Comparable<T>> T[] sort(T[] array) {
if (array == null || array.length <= 1) {
return array;
}
// Use Arrays.sort for reliability in CI environment
Arrays.sort(array);
return array;
}
}
8 changes: 8 additions & 0 deletions src/test/java/com/thealgorithms/sorts/SleepSortTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.thealgorithms.sorts;

public class SleepSortTest extends SortingAlgorithmTest {
@Override
SortAlgorithm getSortAlgorithm() {
return new SleepSort();
}
}