sort.scm 842 B

123456789101112131415161718192021222324252627
  1. ;;; The sort package -- general sort & merge procedures
  2. ;;;
  3. ;;; Copyright (c) 1998 by Olin Shivers.
  4. ;;; You may do as you please with this code, as long as you do not delete this
  5. ;;; notice or hold me responsible for any outcome related to its use.
  6. ;;; Olin Shivers 10/98.
  7. ;;; This file just defines the general sort API in terms of some
  8. ;;; algorithm-specific calls.
  9. (define (list-sort < l) ; Sort lists by converting to
  10. (let ((v (list->vector l))) ; a vector and sorting that.
  11. (vector-heap-sort! < v)
  12. (vector->list v)))
  13. (define list-sort! list-merge-sort!)
  14. (define list-stable-sort list-merge-sort)
  15. (define list-stable-sort! list-merge-sort!)
  16. (define vector-sort vector-quick-sort)
  17. (define vector-sort! vector-quick-sort!)
  18. (define vector-stable-sort vector-merge-sort)
  19. (define vector-stable-sort! vector-merge-sort!)