by Marco van de Voort <marcov@[EMAIL PROTECTED]
>
Nov 22, 2007 at 10:09 AM
On 2007-11-21, Fister <nej@[EMAIL PROTECTED]
> wrote:
> Is there an elegant way to determine which string is mostly represented
in
> a TStringList? For instance if I've got the following the function
should
> return 'Delphi':
>
> StringList[0] := 'Pascal';
> StringList[1] := 'Pascal';
> StringList[2] := 'Delphi';
> StringList[3] := 'Delphi';
> StringList[4] := 'Delphi';
>
> I've made my own solution where I sort the TStringList and loop the list
> until the string changes and then I determine the count and compare it
to
> a max value which is set if the count value if larger than max value.
Can't think of something more. Except if you control the build up of the
tstringlist. See if string exists in sorted list, if exists increase count
in objects field, else addobject item with count tobject(1)