brainfrz

Untitled

Oct 17th, 2015
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.53 KB | None | 0 0
  1.     public static Comparator<Book> sortByTitle = (Book book1, Book book2) -> {
  2.         String bookTitle1 = book1.getTitle().toLowerCase();
  3.         if (bookTitle1.substring(0, 4).equals("the ")) {
  4.             bookTitle1 = bookTitle1.substring(4, bookTitle1.length());
  5.         }
  6.  
  7.         String bookTitle2 = book2.getTitle().toLowerCase();
  8.         if (bookTitle2.substring(0, 4).equals("the ")) {
  9.             bookTitle2 = bookTitle2.substring(4, bookTitle2.length());
  10.         }
  11.  
  12.         return bookTitle1.compareTo(bookTitle2);
  13.     };
Advertisement
Add Comment
Please, Sign In to add comment