Collections.sort(images, new Comparator<Object>() {
public int compare(Object o1, Object o2) {
if (o1 instanceof ItemGroup) {
if (o2 instanceof ItemGroup) {
final ItemGroup i1 = (ItemGroup) o1;
final ItemGroup i2 = (ItemGroup) o2;
return i1.getName().compareTo(i2.getName());
} else {
return -1;
}
}
return 1;