Click to See Complete Forum and Search --> : Sort a CStringArray


Ronny Guenther
March 30th, 1999, 07:13 AM
I need to sort a CStringArray...

Does anyone know an algorithm that does this?


Thank you in advance!


Ronny

Andy Pike
March 30th, 1999, 07:50 AM
I have a Sort Class that will sort a CString array both a-z or z-a. Reply to this with your email address and I'll send you the code.


Cheers

Andy Pike

Karl Spaelti
March 30th, 1999, 03:11 PM
There is a Visual C++ KB article "How to Sort a CStringArray in MFC". Look for it in the KB.


Regards. Karl

pj durai
March 30th, 1999, 09:55 PM
my advise: use Standard C++ template library.

it would be as simple as

#include <string>

#include <vector>

#include <algorithm>

using namespace std;

vector<string> myarray;

myarray.push_back( "some string");

myarray.push_back( "some other string");

.

.

.

sort(myarray.begin(),myarray.end());

viola. you got a sorted array. with STL containers/algoritms you can do all sort of neat things.