Sort Algorithms using Pointer Arrays

Hello!
I'm new in town and I working on sorting Pointer Arrays. I am familiar with the bubblesort, but I'd like to learn a more efficient method. I am including the entire program for reference, but the primary question lies within a function where I demonstrate a bubblesort to a string pointer array. Any tips on other methods of sorting would be much appreciated!

#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include <conio.h>
using namespace std;
void SortNamesDesc(string * Address[][2], int , int );
void pause();
enum columns {Last=0, First=1};


int main()
{
string Names [25][2];
string* Address [25][2];
int sub=0;
int maxElements=0;
fstream dataFile;

dataFile.open("F:\\SPRECHTCOSC1437\\DataFiles\\People.csv",ios::in);
if(!dataFile.is_open())
{
cout<<"Unable to Process"<<endl;
return 999;
}

while(!dataFile.eof())
{
getline(dataFile, Names[sub][Last],',');
getline(dataFile, Names[sub][First],'\n');
Address[sub][Last]= &Names[sub][Last];
Address[sub][First]= &Names[sub][First];
sub++;

}



dataFile.close();
maxElements=sub;

cout<<left<<setw(19)<<"First"
<<setw(22)<<"Last"
<<setw(15)<<"Address of"
<<setw(11)<<"Address of"<<endl
<<setw(19)<<"Name"
<<setw(22)<<"Name"
<<setw(15)<<"First Name"
<<setw(11)<<"Last Name"<<endl;

cout<<setfill('-')
<<setw(67)<<'-'<<endl;
cout<<setfill(' ');

for(int index=0; index<maxElements; index++)
{
cout<<setw(19)<<Names[index][First]
<<setw(22)<<Names[index][Last]
<<setw(15)<<Address[index][First]
<<setw(11)<<Address[index][Last]<<endl;
}
pause();

dataFile.open("F:\\SPRECHTCOSC1437\\InClassActivities\\Unsorted.rpt",ios::out);
if(!dataFile.is_open())
{
cout<<"Unable to Process"<<endl;
return 999;
}

dataFile<<left<<setw(19)<<"First"
<<setw(22)<<"Last"
<<setw(15)<<"Address of"
<<setw(11)<<"Address of"<<endl
<<setw(19)<<"Name"
<<setw(22)<<"Name"
<<setw(15)<<"First Name"
<<setw(11)<<"Last Name"<<endl;

dataFile<<setfill('-')
<<setw(67)<<'-'<<endl;
dataFile<<setfill(' ');

for(int index=0; index<maxElements; index++)
{
dataFile<<setw(19)<<Names[index][First]
<<setw(22)<<Names[index][Last]
<<setw(15)<<Address[index][First]
<<setw(11)<<Address[index][Last]<<endl;
}
dataFile.close();
SortNamesDesc( Address, maxElements, sub);

cout<<left<<setw(19)<<"First"
<<setw(22)<<"Last"
<<setw(15)<<"Address of"
<<setw(11)<<"Address of"<<endl
<<setw(19)<<"Name"
<<setw(22)<<"Name"
<<setw(15)<<"First Name"
<<setw(11)<<"Last Name"<<endl;

cout<<setfill('-')
<<setw(67)<<'-'<<endl;
cout<<setfill(' ');

for(int index=0; index<maxElements; index++)
{
cout<<setw(19)<<*Address[index][First]
<<setw(22)<<*Address[index][Last]
<<setw(15)<<Address[index][First]
<<setw(11)<<Address[index][Last]<<endl;
}

dataFile.open("F:\\SPRECHTCOSC1437\\InClassActivities\\Sorted.rpt",ios::out);
if(!dataFile.is_open())
{
cout<<"Unable to Process"<<endl;
return 999;
}

dataFile<<left<<setw(19)<<"First"
<<setw(22)<<"Last"
<<setw(15)<<"Address of"
<<setw(11)<<"Address of"<<endl
<<setw(19)<<"Name"
<<setw(22)<<"Name"
<<setw(15)<<"First Name"
<<setw(11)<<"Last Name"<<endl;

dataFile<<setfill('-')
<<setw(67)<<'-'<<endl;
dataFile<<setfill(' ');

for(int index=0; index<maxElements; index++)
{
dataFile<<setw(19)<<*Address[index][First]
<<setw(22)<<*Address[index][Last]
<<setw(15)<<Address[index][First]
<<setw(11)<<Address[index][Last]<<endl;
}
dataFile.close();


}
//This is the bubblesort**********************************************
void SortNamesDesc(string * Address[][2], int maxElements, int sub )
{

int limit = maxElements;
bool swap = true;
while(swap)
{
swap=false;
for(int sub=0; sub < limit-1; sub ++)
{
if(*Address[sub][Last] < *Address[sub+1][Last])
{
string * temp = Address[sub][Last];
Address[sub][Last] = Address[sub+1][Last];
Address[sub+1][Last] = temp;

temp = Address[sub][First];
Address[sub][First] = Address[sub+1][First];
Address[sub+1][First] = temp;

swap=true;
}

}
limit--;
}
return;
}
//**********************************
void pause()
{
char ch;

printf("\nPress ENTER to continue..");
do
{
ch = getch();
}while(ch != 13);

printf("\n\n");

return;
}
closed account (j3Rz8vqX)
Sorting can be expensive no matter what, but there are other means:
http://en.wikipedia.org/wiki/Quicksort
Thank you so much for your response. As soon as I have a chance to implement this new technique, I will update my post
Topic archived. No new replies allowed.