Board index » delphi » How to sort a file in Delphi 2.0

How to sort a file in Delphi 2.0

The subject says it all. I would like to know the generally accepted
way to sort a text file in Delphi.
I know I could read it into a TStringlist and sort it, but the files
tend to get a bit big for that.

Any help much appreciated.

Cheers

---
Ian Whitcombe
"I'd hate for you to go,
 Before I let you know,
 That everybody loves you babe, but me" - B.Bragg

 

Re:How to sort a file in Delphi 2.0


How big?

Anyhow, here are two methods off the top of my head:

(1). use multiple TStringLists - if your data will fit in memory - it's
really quite easy.
(2). use a database!! - and index.  Obviously, it would be best to add the
data in with no index then add the index after all data is "in".  Then
write the data out to your new (sorted) textfile.

HTH,

--
Paul Motyer
pa...@linuxserver.pccity.com.au
SoftStuff, Croydon, Vic,  Australia, 3136.

Ian Whitcombe <IWhitco...@ma.ccngroup.com> wrote in article
<425730675...@ma.ccngroup.com>...

Quote

> The subject says it all. I would like to know the generally accepted
> way to sort a text file in Delphi.
> I know I could read it into a TStringlist and sort it, but the files
> tend to get a bit big for that.

> Any help much appreciated.

> Cheers

> ---
> Ian Whitcombe
> "I'd hate for you to go,
>  Before I let you know,
>  That everybody loves you babe, but me" - B.Bragg

Other Threads