Skip to content

Commit

Permalink
fix #2328: sort blogs with an empty title by their hostname
Browse files Browse the repository at this point in the history
  • Loading branch information
maxme committed Mar 6, 2015
1 parent f132045 commit 8373246
Showing 1 changed file with 4 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,10 @@
public class BlogUtils {
public static Comparator<Object> BlogNameComparator = new Comparator<Object>() {
public int compare(Object blog1, Object blog2) {
Map<Object, Object> blogMap1 = (Map<Object, Object>) blog1;
Map<Object, Object> blogMap2 = (Map<Object, Object>) blog2;

String blogName1 = MapUtils.getMapStr(blogMap1, "blogName");
if (blogName1.length() == 0) {
blogName1 = MapUtils.getMapStr(blogMap1, "url");
}

String blogName2 = MapUtils.getMapStr(blogMap2, "blogName");
if (blogName2.length() == 0) {
blogName2 = MapUtils.getMapStr(blogMap2, "url");
}

Map<String, Object> blogMap1 = (Map<String, Object>) blog1;
Map<String, Object> blogMap2 = (Map<String, Object>) blog2;
String blogName1 = getBlogNameOrHostNameFromAccountMap(blogMap1);
String blogName2 = getBlogNameOrHostNameFromAccountMap(blogMap2);
return blogName1.compareToIgnoreCase(blogName2);
}
};
Expand Down

0 comments on commit 8373246

Please sign in to comment.