Skip to content

Commit 06a71a1

Browse files
committed
Delegate Sequence.sort() to Stream.sort()
See #4
1 parent 63a8775 commit 06a71a1

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

src/main/java/io/github/gdejohn/procrastination/Sequence.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@
6060
import static io.github.gdejohn.procrastination.Maybe.when;
6161
import static io.github.gdejohn.procrastination.Pair.bySecond;
6262
import static io.github.gdejohn.procrastination.Predicates.gather;
63-
import static io.github.gdejohn.procrastination.Predicates.greaterThanOrEqualTo;
64-
import static io.github.gdejohn.procrastination.Predicates.lessThan;
6563
import static io.github.gdejohn.procrastination.Predicates.on;
6664
import static io.github.gdejohn.procrastination.Trampoline.call;
6765
import static io.github.gdejohn.procrastination.Trampoline.terminate;
@@ -2433,15 +2431,7 @@ public <A, R> R collect(Collector<? super T, A, ? extends R> collector) {
24332431
* @see Sequence#strictlyDecreasing(Comparator)
24342432
*/
24352433
public Sequence<T> sort(Comparator<? super T> comparator) {
2436-
return Sequence.lazy(
2437-
() -> this.match(
2438-
(head, tail) -> Sequences.concatenate(
2439-
tail.filter(lessThan(head, comparator)).sort(comparator),
2440-
Sequence.cons(head, tail.filter(greaterThanOrEqualTo(head, comparator)).sort(comparator))
2441-
),
2442-
Sequence.empty()
2443-
)
2444-
);
2434+
return Sequence.lazy(() -> Sequence.memoize(this.stream().sorted(comparator)));
24452435
}
24462436

24472437
/**

0 commit comments

Comments
 (0)