Sorting algorithm with arrayLists
<p>I'm trying to make a scheduling program where no two talks can proceed at the same time, although a talk can proceed as the other one ends. After putting the first talk into Scheduler plan, I want to go through each talk in my arrayList and check if there compatible with the last talk in the schedule. </p>

<p>I figure I can check by comparing if the startTime of index i is greater than the endtime of index i-1.</p>

<p>I sorted my talks and lectures by there endTime and inputted the first array. Now I'm having trouble comparing the events and adding the right ones into Scheduler plan.</p>

<pre><code>public class Scheduler {

private  ArrayList&lt;Event&gt; events = new ArrayList &lt;Event&gt;();

public Scheduler(ArrayList&lt;Event&gt; events){ //Constructor
    for (int i=0; i&lt;events.size(); i++)
        this.events.add(events.get(i));
    }

    public ArrayList&lt;Event&gt; getsortSchedule(){ //Sorting Algorithm
        int N = events.size() -1;

            for (int i = 0; i &lt;=(N-1); i++)
        {
                for(int j = 1; j &lt;= N;j++)
                {
                        if(events.get(i).getendTime().compareTo(events.get(j).getendTime()) &gt; 0)  
                        Collections.swap(events, i, j);
                }   
        }


        return events;
    }

    public Scheduler getSchedule(){ //Scheduling attempt
        Scheduler plan = new Scheduler(events);
        this.events.add(events.get(0));

        for (int i=0; i == events.size(); i++)
        {
            //if(events.get(i).getStartTime() &gt; events.get(i).getendTime())
            //if(events.get(i).getStartTime().compareTo(events.get(l).getendTime()) &gt; events.get(i-1).getendTime().compareTo(events.get(l).getendTime()))  
            this.events.add(events.get(i));
        }

        return plan;
    }
</code></pre>