private int RootCompare(RootEntry re1, RootEntry re2) { int compareResult; var catalogHelper = _clientForm.CatalogListViewHelper; var column = catalogHelper.SortColumn; switch (column) { case 0: compareResult = re1.Path.CompareTo(re2.Path); break; case 1: compareResult = re1.VolumeName.CompareTo(re2.VolumeName); break; case 2: compareResult = re1.DirEntryCount.CompareTo(re2.DirEntryCount); break; case 3: compareResult = re1.FileEntryCount.CompareTo(re2.FileEntryCount); break; case 4: compareResult = (re1.DirEntryCount + re1.FileEntryCount).CompareTo(re2.DirEntryCount + re2.FileEntryCount); break; case 5: compareResult = re1.DriveLetterHint.CompareTo(re2.DriveLetterHint); break; case 6: compareResult = re1.Size.CompareTo(re2.Size); break; case 7: compareResult = re1.AvailSpace.CompareTo(re2.AvailSpace); break; case 8: compareResult = re1.TotalSpace.CompareTo(re2.TotalSpace); break; case 9: compareResult = re1.ScanStartUTC.CompareTo(re2.ScanStartUTC); break; case 10: compareResult = re1.ScanDurationMilliseconds.CompareTo(re2.ScanDurationMilliseconds); break; case 11: compareResult = re1.ActualFileName.CompareTo(re2.ActualFileName); break; case 12: compareResult = re1.DescriptionCompareTo(re2, _config); break; default: throw new Exception($"Problem column {column} not handled for sort."); } if (catalogHelper.ColumnSortOrder == SortOrder.Descending) { compareResult *= -1; } return(compareResult); }