i am using only a driver and not a server. I know how to do selection sort for ints but can't figure out how to do it for Strings. I want to sort it my first letter only Here is my code that i started:
private static void selectionSort(S tring [] a)
{
String [] array = a;
int min, temp;
for (int index = 0; index < a.length - 1; index++)
{
min = index;
for (int scan = index + 1; scan < a.length; scan++)
if (a[scan].substring(0,1) < a[min].substring(0,1) )
min = scan;
temp = a[min].substring(0,1) ;
a[min].substring(0,1) = a[index].substring(0,1) ;
a[index].substring(0,1) = temp;
}//close for
}//close selectionSort
help is appreciated
private static void selectionSort(S tring [] a)
{
String [] array = a;
int min, temp;
for (int index = 0; index < a.length - 1; index++)
{
min = index;
for (int scan = index + 1; scan < a.length; scan++)
if (a[scan].substring(0,1) < a[min].substring(0,1) )
min = scan;
temp = a[min].substring(0,1) ;
a[min].substring(0,1) = a[index].substring(0,1) ;
a[index].substring(0,1) = temp;
}//close for
}//close selectionSort
help is appreciated
Comment