Hi, I'm new here, but you'll probably be seeing too much of me before long ;)
My names Daniel.
I have this sort method for sorting (essentially) an array, but it does strange things that i can't quite figure out, and it doesn't sort.
the array is a feature of this class...
class StringCount
{
String [] _words;
int _wordCount;
int [] _wordPlace;
int [] _wordLength; ....
...which works fine.
and i'm just trying to alphabetically sort the string array, and rearrange the int[]s
accordingly.
public static StringCount SCsort(StringCount sortless)
{
for(int a=0;a+1<sortless.wordCount();a++)
{
boolean flag = false;
int i, j;
String tempword;
int tempplace;
int templength;
for(i=0;i<sortless.wordCount()-1;i++)
{
for(j=i+1;j<sortless.wordCount();j++)
{
if((sortless.words()[a]).compareTo(sortless.words()[a+1]) > 0)
{
tempword = sortless.words()[a];
tempplace = sortless.wordPlace()[a];
templength = sortless.wordLength()[a];
sortless.words()[a] = sortless.words()[a+1];
sortless.wordPlace()[a] = sortless.wordPlace()[a+1];
sortless.wordLength()[a] = sortless.wordLength()[a+1];
sortless.words()[a+1] = tempword;
sortless.wordPlace()[a+1] = tempplace;
sortless.wordLength()[a+1] = templength;
System.out.println(tempword);
flag=true;
}
}
}
}
System.out.println(sortless.wordCount());
return sortless;
}
I'd appreciate any help here, cos I can't proceed further into the murky waters of my project until i get this working.