1
I’m with the following method, but in the WHILE line it’s error. netbeans says
"bad operand types for Binary Operator "&&", first type: Boolean, Second type: int".
public boolean insertionSort(String a []) {
if (a == null) return false;
int i,j; String x;
for ( i=0; i < a.length; i++ ) {
x = a[i]; j = i;
while (j>0 && x.compareTo(a[j-1])) {
a[j] = a[j-1];
j--;
}
a[j] = x;
visualizarEtapa(a,i);
}
return true;
}
It worked! But the method was not ordering the values of the vector alphabetically yet. I changed the comparative "==" to ">". It looks like this: while (j>0 && 0 > x.compareTo(a[j-1]))
– Lucas Almeida
I got your code I made some changes, see if it works
– brow-joe