[Lazarus] Lazarus support for Sorting is completely inadequate.

Hans-Peter Diettrich DrDiettrich1 at aol.com
Tue Dec 4 23:55:30 CET 2012


Avishai schrieb:
> My interest is that there be a Sort method that is "Langauge aware"
> and that it Not be driven by Locale.  Letting Locale set a default
> sort method makes sense, but you should be able to override that
> default.

Something like OnCompareItem?

>  As for CaseSensitive Sort, I have tried and failed to think
> of a situation where I wouldn't want a CaseSensitive Sort, assuming
> the Language has Case (Hebrew does not).

There exist enough situations, e.g. the identifiers in Pascal source 
code are case insensitive.

>  It should also have
> "Property SortAscending: Boolean = True".

This can become a property of the sorting procedure.

> For me the only real issue is collecting the proper Sort methods
> (compare functions) for the different languages and constructing a
> wrapper to implement them.  With the help of the Lazarus community, I
> don't think that should be difficult.

Did you already examine all list classes in the libraries, what sorting 
features they have, and how these are different? Then you can suggest a 
more common interface that could be implemented for all these lists.

The general compare function needs a mapping table, from character codes 
(codepoints) into the sort order. Then its mostly stupid work, to 
implement the mapping tables for every language, case sensitivity and 
sorting mode.

Some languages, like German, deserve a comparison function that also 
handles digraphs, so that e.g. 'ae' can sort like 'ä', or just before or 
after 'ä'. In case-insensitive sorting all forms of 'AE', 'Ae' and 'ae' 
have to map to the same sort order value. The same for ligatures or true 
digraphs (Unicode: not canoncial), like 'a¨' standing exactly for 'ä'. 
For such languages I'd suggest to use the Unicode library functions, 
which should already cover all these issues.

DoDi





More information about the Lazarus mailing list