sort custom Array List
<p>I have a class called x which is a array list and needs to be sorted in Decreasing order by Value.
My Class- </p>

<pre><code> public static class x
{
    public int id;
    public double value;
    public x(int _id, double _value)
    {
        id = _id;
        value = _value;
        //System.out.println(Integer.toString(id));
    }

    public Integer getID(){
        return id;
    }
    public double getValue(){
        return value;
    }


    //Sorting
    public static Comparator&lt;x&gt; getComparator(SortParameter... sortParameters) {
        return new xComparator(sortParameters);
    }

    public enum SortParameter {
        VAL_DESCENDING
    }

    private static class xComparator implements Comparator&lt;x&gt; {
        private SortParameter[] parameters;

        private xComparator(SortParameter[] parameters) {
            this.parameters = parameters;
        }

        public int compare(x o1, x o2) {
            int comparison;
            for (SortParameter parameter : parameters) {
                switch (parameter) {
                   case VAL_DESCENDING:
                        comparison = o2.id - o1.id;
                        if (comparison != 0) return comparison;
                        break;

                }
            }
            return 0;
        }
    }

}
</code></pre>

<p>I Call it like:</p>

<pre><code>  cp = x.getComparator(x.SortParameter.VAL_DESCENDING);
  Collections.sort(attr1, cp);
</code></pre>

<p><code>attr1</code> is my array list </p>

<p>Just for Reference I am following <a href="http://stackoverflow.com/a/1421324/787158">this</a> </p>

<p>I am getting error:</p>

<pre><code>cannot find symbol : variable cp    
</code></pre>

<p>I am a newbie to java :(     </p>
