import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

class Item {
    private String name;

    public Item() {
        super();
    }

    public Item(final String name) {
        super();
        this.name = name;
    }

    public String getName() {
        return name;
    }

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

    @Override
    public String toString() {
        return String.format("Item[name=%s]", getName());
    }
}

class ItemTest {
    public static void main(final String[] args) {
        try {
            testSortItemArrByNameExcludingThe();
            testSortItemListByNameExcludingThe();
        } catch (final Exception e) {
            e.printStackTrace();
        }
    }

    public static void testSortItemArrByNameExcludingThe() throws Exception {
        final Item[] itemArr = new Item[] { new Item("The Abacus"),
                new Item("The Killing of Molly Brown"),
                new Item("The What and The Who"),
                new Item("The Fighting Temptations"),
                new Item("Doctor Seusses Cat in the Hat") };

        Arrays.sort(itemArr, new Comparator<Item>() {
            public int compare(Item a, Item b) {
                String newA = a.getName().replaceAll("(?i)^the\\s+", "");
                String newB = b.getName().replaceAll("(?i)^the\\s+", "");
                return newA.compareToIgnoreCase(newB);
            }
        });

        System.out.println("Array Sort:" + Arrays.toString(itemArr));
    }

    public static void testSortItemListByNameExcludingThe() throws Exception {
        final Item[] itemArr = new Item[] { new Item("The Abacus"),
                new Item("The Killing of Molly Brown"),
                new Item("The What and The Who"),
                new Item("The Fighting Temptations"),
                new Item("Doctor Seusses Cat in the Hat") };

        final List<Item> itemList = Arrays.asList(itemArr);
        Collections.sort(itemList, new Comparator<Item>() {
            public int compare(Item a, Item b) {
                String newA = a.getName().replaceAll("(?i)^the\\s+", "");
                String newB = b.getName().replaceAll("(?i)^the\\s+", "");
                return newA.compareToIgnoreCase(newB);
            }
        });

        System.out.println("Lists Sort:" + itemList);
    }
}