for(int comparerRow = 0; comparerRow < rowCount - 1; comparerRow++)
{
for(int compareeRow = comparerRow + 1; compareeRow < rowCount; compareeRow++)
{
for(int columnIndex = 0; columnIndex < columnCount; columnIndex++)
{
}
}
}
The important part is that the inner row loop has to depend on the outer row loop's iteration variable. So it won't start from the beginning over and over again.