출처: http://stackoverflow.com/questions/1106476/group-sorting-a-vector-in-c


static bool CompareWidget(const Widget& w1, const Widget& w2)
{
   
if(w1.GetGroupNumber() != w2.GetGroupNumber())
       
return (w1.GetGroupNumber() < w2.GetGroupNumber());
   
if(w1.GetHeight() != w2.GetHeight())
       
return (w1.GetHeight() < w2.GetHeight();
   
/// etc
   
return false;
}


 
static void SortWidgetVector(WidgetVector& widgetVector)
 
{
      std
::sort(widgetVector.begin(), widgetVector.end(), CompareWidget);
 
}

'프로그래밍 > C/C++' 카테고리의 다른 글

stringstream clear  (0) 2012.07.30
다중벡터 초기화  (0) 2012.07.11
이중 if 문에서의 break  (0) 2012.07.05
ofstream 파일 출력시 floating point 고정 시키는 법  (0) 2012.06.22
vector ifstream  (0) 2012.05.28
Posted by halloRa
,