private static ArrayList<String> alphabetize(ArrayList<String> list) {
    
        int numWords = list.size();
            
        // Change the case of all words in the list to lowercase.
        for (int i = 0; i < numWords; i++) {
        
            String s = list.get(i);
            if (s != null)
                s = s.toLowerCase();
            list.set(i, s);
            
        }
            
        int itemsSorted;

        for (itemsSorted = 1; itemsSorted < numWords; itemsSorted++) {
        
            int loc = itemsSorted - 1;
            
            String s1 = list.get(loc);
            String s2 = list.get(itemsSorted);
            
            // The result of comparing the two strings above.
            int comp;
            try {
                comp = s1.compareTo(s2);
            }
            catch (NullPointerException e) {
                break;
            }
            
            while (loc >= 0 && comp > 0) {
            
                list.set(loc + 1, list.get(loc));
                loc -= 1;
                
                if (loc >= 0)
                    s1 = list.get(loc);
                    
                comp = s1.compareTo(s2);
            
            }
            
            list.set(loc + 1, s2);
        
        } // end for
        
        return list;
    
    } // end alphabetize()