java.lang.IllegalArgumentException: Comparison method violates general.....
1004808Apr 23 2013 — edited Apr 23 2013Below code throws java.lang.IllegalArgumentException: Comparison method violates its general contract!,
Collections.sort( arrayList, new Comparator()
{
public int compare( Object o1, Object o2 )
{
TypeAdapterSort tas1 = ( TypeAdapterSort ) o1;
TypeAdapterSort tas2 = ( TypeAdapterSort ) o2;
if ( tas1.order < tas2.order )
return -1;
else
return 1;
}
} );
class TypeAdapterSort {
int order;
}
I am not sure with what data in arraylist the above code throws the exception, please me know the data that needs to be populated in arraylist so that the exception occurs.