struct Row{ //this could be a template class
int r[3];
//you could overload operator [] here
};
bool Less(Row a, Row b){
return a.r[0]+a.r[1]+a.r[2] < b.r[0]+b.r[1]+b.r[2];//you should use a loop
}
//...
Row array[3] = { {3, 2, 3}, {1, 1, 1}, {2, 2, 2} };//you can do that as long as Row has no ctor
std::sort(array, array+3, Less);//from <algorithm>. you can write one yourself too. just use the Less to compare