stripes@eng.umd.edu (Joshua Osborne) (04/04/91)
Is Perl's sort stable? By that I mean if I have a list of 6 char long scalers,
and ask sort to sort by the last 3 letters and then again by the first 3 will
I have the same effect as if I had sorted by all six in the same place? (I am
asking because I have data sorted by date given in a messy date format, and
I want to sort by user name but preserve the secondary sorting by date... I
could solve the problem without assuming Perl's sort is stable, but why go to
all that extra work if Perl does do a stable sort?).
--
stripes@eng.umd.edu "Security for Unix is like
Josh_Osborne@Real_World,The Multitasking for MS-DOS"
"The dyslexic porgramer" - Kevin Lockwood
"CNN is the only nuclear capable news network..."
- lbruck@eng.umd.edu (Lewis Bruck)lwall@jpl-devvax.jpl.nasa.gov (Larry Wall) (04/09/91)
In article <1991Apr3.224701.9318@eng.umd.edu> stripes@eng.umd.edu (Joshua Osborne) writes:
: Is Perl's sort stable? By that I mean if I have a list of 6 char long scalers,
: and ask sort to sort by the last 3 letters and then again by the first 3 will
: I have the same effect as if I had sorted by all six in the same place? (I am
: asking because I have data sorted by date given in a messy date format, and
: I want to sort by user name but preserve the secondary sorting by date... I
: could solve the problem without assuming Perl's sort is stable, but why go to
: all that extra work if Perl does do a stable sort?).
No, it relies on C's qsort, which is not stable. Sorry...
Larry