Attempting to write an insertion sort to sort an array of strings..
public static void insertionSort(String[] list)
{
for (int i = 1; i <list.length; i++)
{
String currentElement = list[i];
int k;
for (k=i-1; k >= 0 && list[k] > currentElement; k--) //error here
{
list[k+1]=list[k];
}
list[k+1] = currentElement;
}
}
I'm getting the error The operator > is undefined for the argument type, but I thought I had learned in class that you could compare strings with >, <, etc? How would I go about fixing this problem?