From 24b292bc472ba66fa12ddf49ab2ceb0513b3063d Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Fri, 20 Dec 2013 19:52:39 -0800 Subject: #222 Sort albums by year --- src/github/daneren2005/dsub/domain/MusicDirectory.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/github/daneren2005/dsub/domain/MusicDirectory.java b/src/github/daneren2005/dsub/domain/MusicDirectory.java index 24f61311..b5707daf 100644 --- a/src/github/daneren2005/dsub/domain/MusicDirectory.java +++ b/src/github/daneren2005/dsub/domain/MusicDirectory.java @@ -374,7 +374,17 @@ public class MusicDirectory implements Serializable { } else if(!lhs.isDirectory() && rhs.isDirectory()) { return 1; } else if(lhs.isDirectory() && rhs.isDirectory()) { - return lhs.getTitle().compareToIgnoreCase(rhs.getTitle()); + Integer lhsYear = lhs.getYear(); + Integer rhsYear = rhs.getYear(); + if(lhsYear != null && rhsYear != null) { + return lhsYear.compareTo(rhsYear); + } else if(lhsYear != null) { + return -1; + } else if(rhsYear != null) { + return 1; + } else { + return lhs.getTitle().compareToIgnoreCase(rhs.getTitle()); + } } Integer lhsDisc = lhs.getDiscNumber(); -- cgit v1.2.3