hello everybody.. im new here and new to java :)
please help with your expertise
i need to sort an array of string objects..by lexicographical order.
by method compareTo() only.
cant use array.sort() and such.
if i have several words in the array. and i need to enter a new word that is lexicographical y lower from one of the words, how do i make room for it ,move the rest, and put it in the right spot..
i tried bubblesort and it didn\t help..
plz show me an example of sorting from this kind.
forever grateful
[CODE]
public boolean addWord(Word newWord){
boolean work = true;
if (_dic[firstEntry] == null){
_dic[firstEntry] = new Word (newWord.getHeb rewWord(),newWo rd.getEnglishWo rd());
//firstEntry++;}
for (;move<firstEnt ry;move++)
if (_dic[move].getEnglishWord ().compareTo(ne wWord.getEnglis hWord())<0){
firstEntry++;
//_dic[move] =_dic[move+1];
_dic[firstEntry-11] = new Word (newWord.getHeb rewWord(),newWo rd.getEnglishWo rd());}
work = true;
}
return work;
}
[/CODE
please help with your expertise
i need to sort an array of string objects..by lexicographical order.
by method compareTo() only.
cant use array.sort() and such.
if i have several words in the array. and i need to enter a new word that is lexicographical y lower from one of the words, how do i make room for it ,move the rest, and put it in the right spot..
i tried bubblesort and it didn\t help..
plz show me an example of sorting from this kind.
forever grateful
[CODE]
public boolean addWord(Word newWord){
boolean work = true;
if (_dic[firstEntry] == null){
_dic[firstEntry] = new Word (newWord.getHeb rewWord(),newWo rd.getEnglishWo rd());
//firstEntry++;}
for (;move<firstEnt ry;move++)
if (_dic[move].getEnglishWord ().compareTo(ne wWord.getEnglis hWord())<0){
firstEntry++;
//_dic[move] =_dic[move+1];
_dic[firstEntry-11] = new Word (newWord.getHeb rewWord(),newWo rd.getEnglishWo rd());}
work = true;
}
return work;
}
[/CODE
Comment