[Lazarus] Lazarus support for Sorting is completely inadequate.

Alexander Klenin klenin at gmail.com
Sun Dec 2 09:39:32 CET 2012


On Sun, Dec 2, 2012 at 3:53 AM, Juha Manninen <juha.manninen62 at gmail.com> wrote:
> The default sort routine is quicksort and it works well in every situation.
> It uses a compare function which returns -1, 0 or 1 depending on its parameters.
> You need different compare functions, not different sort functions to
> support the languages.
> Mattias tried to explain it already.
> There could also be other sort functions / algorithms like merge sort
> or even bubble sort, but that is another issue.

There are two independent issues here.
First is a possible lack of Unicode collation support in Lazarus -- I
am not sure about it,
but I was under the impression that UTF8Compare provides such support.
If I am wrong, then it is certainly a serious omission.

The other is a lack of standard algorithm and data structures support.
This is a most prominent factor behind the sharp decline of Pascal's relevancy
as a teaching language.
In fact, just this Friday I performed an informal presentation at the
conference of
top Russian teachers of informatics (it.mipt.ru/conference)
The main topic was "Free Pascal is not dead, please do not abandon it yet".

Recent addition of FCL-STL was a great move which promises some future
for Pascal in education. It has many shortcomings, but is definitely a
step in right direction,
compared to the current mess. I hope it did not come too late.

> Having separate quicksort routines in many containers is not as bad as
> it sounds. The quicksort routine is short and well-established (will
> not change) and it must use the container's data directly inside a
> tight loop.
Not quite so. On the one hand, quicksort is unstable, which is not good
when sorting non-trivial containers. On the other, constant factor in
sorting algorithms
is usually dominated by calls to the comparator, which can not be
eliminated without generics.

--
Alexander S. Klenin




More information about the Lazarus mailing list