http://www.codeguru.com/forum/archive/index.php/t-215414.html
這篇貼子幫了大忙。有一個回貼這樣說到:
#include <algorithm>
...
// Note the *only* change is the template type!
CArray<unsigned char, unsigned char> MyCArray;
//...
std::sort( MyCArray.GetData(), MyCArray.GetData() + MyCArray.GetSize());
It doesn't matter whether it's a CArray of strings, ints, chars, doubles, widgets, or your own class. As long as the items are comparable using operator < (which is what std::sort uses internally), the std::sort will work.
當然,sort()裏如果用到自定義比較函數,自己寫了。。。