Maybe someone help me. I try to sort names in alphabetic order and get the folowing output for example: Altius Brasil ball chiken. How can I sort names in case sensitive order: Altius ball Brasil chiken?
Thanks in advance
#include <iostream>
#include <string>
using namespace std;
void sort(string arr[], const int size);
int findmin(string arr[],int start,int finish);
void swap ( string& first, string& second);
void print (string arr[], const int size);
int main()
{
const int size=10;
string names [size];
cout<< " Input name:" <<endl;
for (int i=0;i<size;i++)
{
cin>>names[i];
}
sort(names,size);
print(names,size);
system ("pause");
return 0;
}
void sort(string arr [], const int size)
{
int min=0;
for (int i=0;i<size;i++)
{
min=findmin (arr, i, size-1);
swap(arr[i],arr[min]);
}
}
int findmin (string arr [],int start,int finish)
{
int min=start;
for (int i=start+1;i<=finish;i++)
{
if (arr[i]<arr[min])
min=i;
}
return min;
}