Does Flexcel ensure that sorting a range on a specific column will maintain the original sequence within multiple instances of the same value in the specified column? Or is there an option to guarantee this? If not, is there an example of how to use a TComparer, which I could not find documented, to achieve the same result?
FlexCel uses MergeSort instead of QuickSort specifically because it is a stable sort (see Sorting algorithm - Wikipedia ). But it really depends on where you are using it: If you are doing a xls.Sort to sort a range it will indeed be stable. The =Sort() function is also stable. In general, wherever we sort in our code we use a stable sort. But if you are for example using the Sort property of a TDataSet, well, there it will be what TDataSet uses (which is most likely quicksort).
Where we have control, it is MergeSort
is there an example of how to use a TComparer
You can't really get stability by changing TComparer, this is a characteristic of the algorithm used for sorting. Sadly the most used one (and the default in Delphi) is QuickSort, which is not stable. MergeSort is not publicly available from FlexCel (which means we reserve the right to remove it / change it in the future, but at this point it is really unlikely that we will). But if you want to use it on your own code, you can use the unit
_UCoreClasses.MergeSort and from there call TMergeSort.Sort.