Created
December 16, 2014 08:27
-
-
Save nbadal/83a168849e026b33f88e to your computer and use it in GitHub Desktop.
Artist Alphabetizer Comparator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Ignores case, and ignores prefix of "The" */ | |
public class ArtistAlphabetizer implements Comparator<String> { | |
@Override | |
public int compare(String a, String b) { | |
int aIdx = a.toLowerCase().startsWith("the ") ? 4 : 0; | |
int bIdx = b.toLowerCase().startsWith("the ") ? 4 : 0; | |
return a.substring(aIdx).compareToIgnoreCase(b.substring(bIdx)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment