Sort a Java List Alphabetically First then By Numbers

Here's an example of doing custom sort on a list of objects by field value starting with a alphabet to come before field value starting with a number:

Example

import java.util.Comparator;

public class Book {
    private String id;
    private String name;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Book [id=" + id + ", name=" + name + "]";
    }

    public static class Comparators {

        public static Comparator ORDER_BY_NAME_ASC = new Comparator() {

            @Override
            public int compare(Book book1, Book book2) {
                return existsNumber(book1.getName(), book2.getName())
                        ? isNumber(book1.getName()) ? 1 : -1
                        : book1.getName().compareToIgnoreCase(book2.getName());
            }
        };

        private static boolean isNumber(String s) {
            String pattern = "\\d.*";
            return s.matches(pattern);
        }

        private static boolean existsNumber(String o1, String o2) {
            return isNumber(o1) || isNumber(o2);
        }

    }
}

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class SortingExample {

    public static void main(String[] args) {

        List books = new ArrayList<>();

        Book book1 = new Book();
        book1.setId("1");
        book1.setName("Candid");
        books.add(book1);

        Book book2 = new Book();
        book2.setId("2");
        book2.setName("Tutorials");
        books.add(book2);

        Book book3 = new Book();
        book3.setId("3");
        book3.setName("ASP dot net");
        books.add(book3);

        Book book4 = new Book();
        book4.setId("4");
        book4.setName("25 skills");
        books.add(book4);

        Book book5 = new Book();
        book5.setId("5");
        book5.setName("14 Days Learning");
        books.add(book5);

        Collections.sort(books, Book.Comparators.ORDER_BY_NAME_ASC);

        System.out.println("Books " + books);

    }
}
Output
Books [Book [id=3, name=ASP dot net], Book [id=1, name=Candid], Book [id=2, name=Tutorials], Book [id=4, name=25 skills], Book [id=5, name=14 Days Learning]]