Sort list on base of multiple criteria
<p>I would like to sort a list on base of multiple criteria. </p>

<pre><code>public class CustomerComparator implements Comparator&lt;Customer&gt; {

    public int compare(Customer customer1, Customer customer2) {
        int comparison = -1;
        comparison = customer2.getCustomerPriority().compareTo(customer1.getCustomerPriority());
        if( comparison == 0 ) {
            comparison = customer1.getCustomerNumber().compareTo(customer2.getCustomerNumber());
        }
    return comparison;
    }
}
</code></pre>

<p>Basically, I want to sort in following order. Customer with higher priority should be on top of the list, and if two customers have same priority than one with lower customer number should go first. </p>

<p>Original:</p>

<pre><code>Customer Priority
1        0       
2        0
3        1
4        0
5        0
</code></pre>

<p>it should be sorted as below:</p>

<pre><code>Customer   Priority
3          1
1          0
2          0
4          0
5          0
</code></pre>

<p>Thanks for help.
DD</p>
