I would recommend implementing a compareTo() method that determines which color comes before which.
* Blue comes before green.
* Returns less than 0 if item1 comes before item2
* Returns 0 if item1 comes at the same place as item2
* Returns greater than 0 if item1 comes after item2
public static int compareTo(ColorItem item1, ColorItem item2)
int val1 = 0;
int val2 = 0;
if(item1 == BLUE)
val1 = 1;
val1 = 2;
if(item2 == BLUE)
val2 = 1;
val2 = 2;
return val1 - val2;
Then, somewhere in your code implement a standard sorting algorithm (say, selection sort because it's very easy).