[plt-scheme] Destructive Sort. Really dumb question.

From: bullockbefriending bard (kinch1967 at gmail.com)
Date: Thu May 22 13:15:59 EDT 2008

(require (lib "list.ss"))

(let ((y (list 9 8 7 1 11)))
    (sort y <))

=> (1 7 8 9 11)

and all is well with the world.

(let ((y (list 9 8 7 1 11)))
    (sort! y <))

=> (1 7 8 9 11)

ditto.

(let ((y (list 9 8 7 1 11)))
    (sort! y <)
    y)

=> (8 9 11)

major screen brain impedance mismatch here.

I guess I must be misunderstanding something. If sort! is an in-place
sort, why don't I see (1 7 8 9 11) ?


Posted on the users mailing list.