Sorting help!
Stefan Schmiedl
s at xss.de
Thu Nov 15 18:37:13 UTC 2001
Jon Hylands (2001-11-15 11:13):
> On Thu, 15 Nov 2001 16:04:59 +0100, Stefan Schmiedl <s at xss.de> wrote:
>
> > > <title>,<name>,<reference>,<number>
> > >
> > > Sort would have to do in ascending order of
> > > <title>,<name>,<reference>,<number>
> >
> > as you do not need to switch columns, you
> > could just read the file line-by-line into
> > a large array of strings and then use the
> > standard sort method for arrays.
> >
> > Nah, it can't be that simple. What am I overlooking here?
>
> Because the strings are not all the same length. They are comma-delimited.
so?
sorting the <title> field strings will work, even
if they have different lengths. Access to the <name>
field is only necessary if the <title> field of the
records in question is identical, hence has the same
length. So sorting the name field only occurs with
identical "prefixes", which have no effect on sort order.
>
> One point to make for sorting: On large sets, it is almost always
> significantly faster to read all the objects you are going to sort into a
> normal collection and the sort the whole thing, rather than doing an
> insertion sort item by item.
of course. I meant the same above, but might have garbled my words.
s.
--
Stefan Schmiedl
EDV-Beratung, Programmierung, Schulung
Loreleystr. 5, 94315 Straubing, Germany
Tel. (0 94 21) 74 01 06
Public Key: http://xss.de/stefan.public
shhhh ... I can't hear my code!
More information about the Squeak-dev
mailing list
|