Looks to me like bubbleSortDesc
is sorting in ascending order, and BubbleSortAsc
doesn't work at all:
//In BubbleSortAsc
result=names[i].compareToIgnoreCase(names[i]);
//result == 0, since names[i] is definitely equal to names[i]
if(result>0)
{
//Never reached
temp=names[i-1];
names[i-1]=names[i];
names[i]=temp;
}
So, you should have, again in BubbleSortAsc:
result=names[i].compareToIgnoreCase(names[i+1]);
if(result>0) //names[i] > names[i+1], so swap them.
And in BubbleSortDesc:
result=names[i].compareToIgnoreCase(names[i+1]);
if(result<0) // This was backwards. If names[i] < names[i+1], you need to swap, for descending order.