From 4491b668724c6756711ea90c3f41db7236981fd0 Mon Sep 17 00:00:00 2001 From: mitosagi <54105954+mitosagi@users.noreply.github.com> Date: Sat, 4 Apr 2020 03:09:46 +0900 Subject: [PATCH] Make null sortable --- .../newpipe/local/bookmark/BookmarkFragment.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/bookmark/BookmarkFragment.java b/app/src/main/java/org/schabi/newpipe/local/bookmark/BookmarkFragment.java index f1a18b8084e..d99a05976b4 100644 --- a/app/src/main/java/org/schabi/newpipe/local/bookmark/BookmarkFragment.java +++ b/app/src/main/java/org/schabi/newpipe/local/bookmark/BookmarkFragment.java @@ -62,8 +62,19 @@ private static List merge( items.addAll(localPlaylists); items.addAll(remotePlaylists); - Collections.sort(items, (left, right) -> - left.getOrderingName().compareToIgnoreCase(right.getOrderingName())); + Collections.sort(items, (left, right) -> { + String on1 = left.getOrderingName(); + String on2 = right.getOrderingName(); + if (on1 == null && on2 == null) { + return 0; + } else if (on1 != null && on2 == null) { + return -1; + } else if (on1 == null && on2 != null) { + return 1; + } else { + return on1.compareToIgnoreCase(on2); + } + }); return items; }