Probably you can use flags to indicate the state when you enabled/disabled sorting:
dontSort = true;
try
{
Rows.CollapseAll();
}
finally
{
dontSort = false
}
and in sorting:
private void OnColumnSortOrderChanging(object sender, object column, SortOrder value, ref bool sorted)
{
if (!dontSort)
sorted = SortOnColumns(flyGrid.Columns.SortColumns);
}