Sorting array list in Java
<p>I have following class. In this, Iris is another class with some attributes.</p>

<pre><code>public class Helper {

    Iris iris;
    double distance;

    public Helper(Iris iris, double distance) {
        this.iris = iris;
        this.distance = distance;
    }
}
</code></pre>

<p>I want to sort an array list of this (i.e List &lt; Helper > helperList), descending based on distance parameter. I have written the following method but it is not working.</p>

<pre><code>public void sort(){
for(int k=0; k &lt; helperList.size(); k++)
        {
            double distance = helperList.get(k).distance; 

             for(int l=0; l &lt; helperList.size(); l++)
             {
                 Helper temp = helperList.get(l);
                 if( distance &lt; temp.distance )
                 {
                     helperList.set(l, helperList.get(k));
                     helperList.set(k, temp);
                 }
            }
        }
}
</code></pre>

<p>Can anybody suggest a solution?</p>
