I have a problem with sort, as implemented currently.
First, let us see that, as currently implemented, Sort procedure of tsWorkSheet calls DoCompareCells, which then iterates through SortParams.Keys and for each Key:
-- if OnCompareCells event is assigned, calls it for each key
-- or (if the event is not assigned) calls DefaultCompareCells with SortOptions of the current key.
DefaultCompareCells method, according to SortOptions decides whether numbers go before text, whether direction should be ascending or not, etc.
But, when it falls to comparing two text cells, it uses UTF8CompareString (or UTF8CompareText, if ssoCaseInsensitive is in options) from LazUTF8 unit.
I don't think it is the best decision.
What other FCL and LCL controls use as default is AnsiCompareText (or AnsiCompareString) from sysutils. That is what TStringList uses for sorting, that is what TBufDataset uses, etc.
Contrary to their "Ansi" name, these functions actually use currently installed WideStringManager for comparing text and they are expected to sort utf8 text well.
My problem is that I want text sorting somewhat different from LazUtf8.Utf8CompareText, and I have WideStringManager adjusted to what I need (I always do it on application start), but unlike other components, fpSpreedSheet ignores WideStringManager.
Then, I wanted to use OnCompareCells. I wanted to copy DefaultCompareCelss, and just replace the text comparing functions, as mentioned above. But then, this is a problem:
Unlike DefaultCompareCells function, OnCompareCells does not have SortOptions parameter, which is a problem. I want to use SortOptions first, just like DefaultCompareCells uses them, but only to change text comparing. This is not possible, as SortOptions are not passed to the event.
Of course, as a workaround, I can replace these function calls directly inside the source or DefaultCompareCells implementation, but I really don't like such "solutions".
Perhaps, if you don't like to change the default behaviour, you could add another event - OnCompareText, so that DefaultCompareCells takes care of sorting options (numbers before text, positioning of empty cells, the direction - asc. or desc.), but only when it comes to comparing text cells, then, if this new event is assigned, use it instead currently default functions from LazUTF8.