From fb392dd3314b2690a7a1df4b566973726e9e8cc4 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Wed, 2 Apr 2008 01:28:09 +0000 Subject: [PATCH] adjust sort keyword arguments and docs svn: r9131 --- collects/scheme/private/list.ss | 2 +- collects/scribblings/reference/pairs.scrbl | 52 +++++++++++++--------- 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/collects/scheme/private/list.ss b/collects/scheme/private/list.ss index 5810dde1a6..4716850ec3 100644 --- a/collects/scheme/private/list.ss +++ b/collects/scheme/private/list.ss @@ -29,7 +29,7 @@ (for-syntax "stxcase-scheme.ss")) (provide sort) - (define (sort lst less? #:key [getkey #f] #:cache-keys [cache-keys? #f]) + (define (sort lst less? #:key [getkey #f] #:cache-keys? [cache-keys? #f]) (unless (list? lst) (raise-type-error 'sort "proper list" lst)) (unless (and (procedure? less?) (procedure-arity-includes? less? 2)) (raise-type-error 'sort "procedure of arity 2" less?)) diff --git a/collects/scribblings/reference/pairs.scrbl b/collects/scribblings/reference/pairs.scrbl index a50c01e303..3e88fb7f1e 100644 --- a/collects/scribblings/reference/pairs.scrbl +++ b/collects/scribblings/reference/pairs.scrbl @@ -327,8 +327,8 @@ Returns @scheme[(remove* v lst eqv?)].} @defproc[(sort [lst list?] [less-than? (any/c any/c . -> . any/c)] - [#:key key (any/c . -> . any/c) values] - [#:cache-keys cache-keys boolean? #f]) + [#:key extract-key (any/c . -> . any/c) (lambda (x) x)] + [#:cache-keys? cache-keys? boolean? #f]) list?]{ Returns a list sorted according to the @scheme[less-than?] procedure, @@ -336,31 +336,41 @@ Returns a list sorted according to the @scheme[less-than?] procedure, the first is less than (i.e., should be sorted earlier) than the second. -The sort is stable: if two elements of @scheme[lst] are ``equal'' +The sort is stable; if two elements of @scheme[lst] are ``equal'' (i.e., @scheme[proc] does not return a true value when given the pair in either order), then the elements preserve their relative order - from @scheme[lst] in the output list. To guarantee this, you should + from @scheme[lst] in the output list. To preserve this guarantee, use @scheme[sort] with a strict comparison functions (e.g., @scheme[<] or @scheme[string