Use Comparator's comparing(), nullsLast() and reversed() methods.
This commit is contained in:
parent
290428b981
commit
abcacf8c74
7 changed files with 23 additions and 22 deletions
|
|
@ -18,6 +18,7 @@ import org.schabi.newpipe.extractor.stream.VideoStream;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -265,10 +266,8 @@ public final class ListHelper {
|
|||
*/
|
||||
private static void sortStreamList(final List<VideoStream> videoStreams,
|
||||
final boolean ascendingOrder) {
|
||||
Collections.sort(videoStreams, (o1, o2) -> {
|
||||
final int result = compareVideoStreamResolution(o1, o2);
|
||||
return result == 0 ? 0 : (ascendingOrder ? result : -result);
|
||||
});
|
||||
final Comparator<VideoStream> comparator = ListHelper::compareVideoStreamResolution;
|
||||
Collections.sort(videoStreams, ascendingOrder ? comparator : comparator.reversed());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue