# Using String ToUpper, Sorting an Array of string without CaseSensitive

I need to sort an array of string where I don't want the Capitals to be smaller then the normal case.

Example A = a

I guess using ToUpper will help me but I can't get it to work.
Or maybe there is another way to do it .

Thank you
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Author Commented:
Here is what I got so far ,
It display the list not even in Order

void Sort(string LIST[],string TYPE[],int n)
{

string tmp;

char TEMP[2000][200];
string TEMP2[2000];
for (int i = 0 ; i < n ; i++)
{
strcpy(TEMP[i],LIST[i].c_str());
int j = 0;
do
{
if(TEMP[i][j] >= 97 && TEMP[i][j] <= 122 )
TEMP[i][j] -= 32;
j++;
}while(TEMP[i][j]!=0);
TEMP2[i] = TEMP[i];
}

for (int i = 0 ; i < n ; i++)

//This is for Debugging Purposes
cout << TEMP2[i] << " " << TEMP[i]<< LIST[i] << endl;

for (int i=0; i<n-1; i++) {
for (int j=0; j<n-1-i; j++){
//this is to be able to find repeated words since , I dont want repetition
if (LIST[j+1] == LIST[j]){
LIST[j] = "";
TYPE[j] = "";
}//End of IF
else if (TEMP2[j+1] < TEMP2[j]) {  /* compare the two neighbors */
tmp = LIST[j];           /* swap a[j] and a[j+1]      */
LIST[j] = LIST[j+1];
LIST[j+1] = tmp;
tmp = TYPE[j];           /* swap a[j] and a[j+1]      */
TYPE[j] = TYPE[j+1];
TYPE[j+1] = tmp;
}//End Of ElseIF
}//End of Inner For Loop
}//End of Outer For Loop

}//End Of Sort Function
Commented:
Do you need to preserve the original capitalization after sorting and do you need to remove duplicates?
Author Commented:
yes, well I created 2 function, void SORT and void SORTWITHOUTREMOVE

and I need to keep the original Case after , this is why Im doing the check on the TEMP2 but affecting the actual LIST.

Author Commented:
Ok I found the problem , I was doing the check on TEMP2 but  I wasnt  swapping in TEMP2.

Is there a way to remove my question ?

SInce I got the aswer (for the points).
Commented:
Author Commented:
void Sort(string LIST[],string TYPE[],int n)
{

string tmp;

char TEMP[2000][200];
string TEMP2[2000];
for (int i = 0 ; i < n ; i++)
{
strcpy(TEMP[i],LIST[i].c_str());
int j = 0;
do
{
if(TEMP[i][j] >= 97 && TEMP[i][j] <= 122 )
TEMP[i][j] -= 32;
j++;
}while(TEMP[i][j]!=0);
TEMP2[i] = TEMP[i];
}

for (int i=0; i<n-1; i++) {
for (int j=0; j<n-1-i; j++){
if (TEMP2[j+1] == TEMP2[j]){
//cout << "False" << endl;
LIST[j] = "";
TYPE[j] = "";
TEMP2[j] = "";

}//End of IF
else if (TEMP2[j+1] < TEMP2[j]) {  /* compare the two neighbors */
//cout << "True" << endl;
tmp = LIST[j];           /* swap a[j] and a[j+1]      */
LIST[j] = LIST[j+1];
LIST[j+1] = tmp;
tmp = TEMP2[j];           /* swap a[j] and a[j+1]      */
TEMP2[j] = TEMP2[j+1];
TEMP2[j+1] = tmp;
tmp = TYPE[j];           /* swap a[j] and a[j+1]      */
TYPE[j] = TYPE[j+1];
TYPE[j+1] = tmp;
}//End Of ElseIF
}//End of Inner For Loop
}//End of Outer For Loop

}//End Of Sort Function

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.