I'm current doing insertion sorts with ArrayList and I'm getting java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at replace.get(insertindex).setTitle(next); . I understand there is nothing at index 0 to get that why it resulting in the error.
** I realized my code is totally wrong for sorting ArrayList, can anyone guide me in the right direction for sorting ArrayList? Thanks- I don't understand how to replace an empty ArrayList at a certain index with the data of another ArrayList.
public static void sortTitles(List<Movie2>list ,List<Movie2> replace, int order)
    {
        if(order == 1)
        {
            for(int x = 0 ; x < list.size();x++)
            {
                String next = list.get(x).getTitle();
                int insertindex = 0 ;
                int k = x;
                while(k > 0 && insertindex == 0 )
                {
                    if(next.compareTo(replace.get(k-1).getTitle()) > 0)
                    {
                        insertindex = k;
                    }
                    else
                    {
                        replace.get(k).setTitle(replace.get(k-1).getTitle() );    
                    }
                    k--;
                }
                System.out.println(next);
                replace.get(insertindex).setTitle(next);
                System.out.println(list.get(x).getTitle());
            }
        }
    }