Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2005 Nov : Order a StringList?

www.cryer.info
Managed Newsgroup Archive

Order a StringList?

Subject:Order a StringList?
Posted by:"Glenn" (nospamhelp@key-data.co.uk)
Date:Tue, 15 Nov 2005 14:02:35

Hi I have a problem with ordering a string list that i then write to a
TListBox

StatNum is a string that is then converted to an integer and then the string
list is ordered...except it isn't ordered as required where I have StatNum =
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21

the list is ordered like

1,10,11,12,13,14,15,16,17,18,19,2,20,21 etc but I would like the list
ordered numerically

This is tha guts of what I do

  { write to the string list }
    //where StatNum is a Variant field type
       StatNum:=Copy(SearchRec.Name,CommaPos+2,StopPos-CommaPos-2);
       StatNum:=StrToInt(StatNum);
       TempList.Add(StatNum);//order on statement number

      end;
    until SysUtils.FindNext(SearchRec) <> 0;
    {Order the string list}
     TempList.Sort;//why doesn't htis order as expected?

Thanks for you time and any suggestions

--
Kind Regards

Glenn Greatwood
Key-Data Systems
www.key-data.co.uk

Replies:

www.cryer.info
Managed Newsgroup Archive