Skip to content

Instantly share code, notes, and snippets.

@nbadal
Created December 16, 2014 08:27
Show Gist options
  • Save nbadal/83a168849e026b33f88e to your computer and use it in GitHub Desktop.
Save nbadal/83a168849e026b33f88e to your computer and use it in GitHub Desktop.
Artist Alphabetizer Comparator
/** 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