private bool Sort()
{
// Optimistically use the last sort order and check to see if that works. This helps the case
// where elements with large numbers of attributes are repeated.
if (_indeces != null && _indeces.Length == _attributeCount && IsSorted())
return true;
object[] newIndeces = new object[_attributeCount];
for (int i = 0; i < newIndeces.Length; i++)
newIndeces[i] = i;
_indeces = newIndeces;
Array.Sort(_indeces, 0, _attributeCount, this);
return IsSorted();
}