By default Arrays.sort(Object[]) will try to cast object to Comparable and use them for sorting algorithm.
In order to make sorting happen, you need the following:
public class DiceComparator implements Comparator<Dice>{
@Override
public int compare(final Dice o1, final Dice o2) {
//here comes logic for comparison
return 0;
}
}
Arrays.sort(YahtzeeGUI.getGame().getDice(), new DiceComparator());
Another possibility to let Dice implement Comparable
public class Dice implements Comparable<Dice>{
@Override
public int compareTo(Dice o) {
//here comes logic for comparison
return 0;
}
}
Arrays.sort(YahtzeeGUI.getGame().getDice());