Sort of integers in CList

how to sort array of integers contained in CList.

Ex:
CList<int,int> mylist;
mylist.Addtail(12);
mylist.Addtail(10);
mylist.Addtail(15);
mylist.Addtail(2);
mylist.Addtail(7);

pos = mylist.GetHeadpostion();
for(int i = 0; i<mylist.getcount(); i++)
cout << mylist.getnext(pos);

the out is 12 , 10 , 15, 2 , 7
is there any way to sort the data in ascending order......

when out put it should display
2 ,7 ,10, 12, 15
[504 byte] By [raja1] at [2007-11-18 17:45:44]
# 1 Re: Sort of integers in CList
If you used the search facility in dev-archive and searched for "CList sort", you would have found your answer:

http://www.dev-archive.com/forum/showthread.php?s=&threadid=244122&highlight=CList

Or you can use std::list, which has a sort() function.

Regards,

Paul McKenzie
Paul McKenzie at 2007-11-11 1:25:42 >
# 2 Re: Sort of integers in CList
thanks paul
i used std::sort method but getting compile time errors saying
error C2039: 'sort' : is not a member of 'std'

ex of code

CArray<int,int> tempArray;
for (int i=0; i<mylist.GetCount(); i++)
tempArray.Add(mylist.GetAt(mylist.FindIndex(i)));

// Sort the CArray
using namespace std;
std::sort(tempArray.GetData(), tempArray.GetData() + tempArray.GetSize());

// CArray => CList
mylist.RemoveAll();
for ( i=0; i<tempArray.GetSize(); i++)
mylist.AddTail(tempArray.GetAt(i));
raja1 at 2007-11-11 1:26:42 >
# 3 Re: Sort of integers in CList
used std::sort method but getting compile time errors saying error C2039: 'sort' : is not a member of 'std'

#include <algorithm>
PadexArt at 2007-11-11 1:27:44 >