I'm trying to have my program find duplicates in an array of strings, and if it finds one, it swaps the duplicate to itemamount - 1, adds +1 to the WordAmt for that word, and moves the loop one spot down. I just am not sure how to properly do this. Everything works up to the swap function, which swaps as intended and lists all the words in alphabetical order. I just need all duplicate words to properly be swapped away and the WordAmt for that word to be added.
void sortArray(WordStruct Words[1000], int itemamount)
{
int indexMax, j, first;
for (indexMax = itemamount - 1; indexMax > 0; indexMax--)
{
first = 0;
for (j = 1; j <= indexMax; j++)
{
if (Words[first].Word < Words[j].Word)
first = j;
}
swap(Words, first, indexMax);
if (j > 0)
{
if (Words[first].Word == Words[j].Word)
{
Words[j].WordAmt++;
swap(Words, first, itemamount - 1);
itemamount--;
}
}
}
return;
}