private int CompareRecords(int record1, int record2)
{
int lenIndexDesc = _indexFields.Length;
for (int i = 0; i < lenIndexDesc; i++)
{
int c = _indexFields[i].Column.Compare(record1, record2);
if (c != 0)
{
if (_indexFields[i].IsDescending) c = -c;
return c;
}
}
long id1 = _table._recordManager[record1] == null ? 0 : _table._recordManager[record1].rowID;
long id2 = _table._recordManager[record2] == null ? 0 : _table._recordManager[record2].rowID;
int diff = (id1 < id2) ? -1 : ((id2 < id1) ? 1 : 0);
// if they're two records in the same row, we need to be able to distinguish them.
if (diff == 0 && record1 != record2 &&
_table._recordManager[record1] != null && _table._recordManager[record2] != null)
{
id1 = (int)_table._recordManager[record1].GetRecordState(record1);
id2 = (int)_table._recordManager[record2].GetRecordState(record2);
diff = (id1 < id2) ? -1 : ((id2 < id1) ? 1 : 0);
}
return diff;
}