I have a GridView with around 6k rows in it. When I click the column header to sort the rows, some columns are fast (a second or two) and some are very slow (45 seconds or so). it looks like the difference is that the slow ones only have a tiny number of distinct values in them. For example my "Name" column is mostly unique per row, and it sorts in a couple second, but my "Excluded" column only shows "No" or "Yes" (about 98% "No" and 2% "Yes") and it takes 45 seconds to sort by.
It looks like the problem is that your sort algorithm does not deal with this problem scenario well due to almost all the items being identical. My profiler shows that with the Name column most of the time from HybridIndex.PerformQuickSort is in List.BinarySearch and that GridViewRowInfoComparer.Compare only gets called about 100k times. But with the "Excluded" column most of the time is in GridViewRowInfoComparer.Compare which is called a whopping 17M times.
I don't think this data scenario is uncommon, so I think there should be some way to handle this. If I could tell this column to use a different sort algorithm that would be fine.
It looks like the problem is that your sort algorithm does not deal with this problem scenario well due to almost all the items being identical. My profiler shows that with the Name column most of the time from HybridIndex.PerformQuickSort is in List.BinarySearch and that GridViewRowInfoComparer.Compare only gets called about 100k times. But with the "Excluded" column most of the time is in GridViewRowInfoComparer.Compare which is called a whopping 17M times.
I don't think this data scenario is uncommon, so I think there should be some way to handle this. If I could tell this column to use a different sort algorithm that would be fine.