[armedbear-cvs] r13838 - trunk/abcl/src/org/armedbear/lisp

mevenson at common-lisp.net mevenson at common-lisp.net
Wed Feb 1 08:24:18 UTC 2012


Author: mevenson
Date: Wed Feb  1 00:24:17 2012
New Revision: 13838

Log:
Partially ddresses #196:  STABLE-SORT now works for non-list sequences.

Modified:
   trunk/abcl/src/org/armedbear/lisp/sort.lisp

Modified: trunk/abcl/src/org/armedbear/lisp/sort.lisp
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/sort.lisp	Tue Jan 31 15:01:45 2012	(r13837)
+++ trunk/abcl/src/org/armedbear/lisp/sort.lisp	Wed Feb  1 00:24:17 2012	(r13838)
@@ -42,7 +42,16 @@
 (defun stable-sort (sequence predicate &rest args &key key)
   (sequence::seq-dispatch sequence
     (sort-list sequence predicate key)
-    (quick-sort sequence 0 (length sequence) predicate key)
+;;; Jorge Tavares: 
+;;; As a quick fix, I send in attach a patch that uses in stable-sort merge
+;;; sort for all sequences. This is done by coercing the sequence to list,
+;;; calling merge sort and coercing it back to the original sequence type.
+;;; However, as a long term improvement, the best solution would be to
+;;; implement a merge sort for non-list sequences.
+    (coerce (sort-list (coerce sequence 'list) 
+		       predicate
+		       key)
+	    (type-of sequence))
     (apply #'sequence:stable-sort sequence predicate args)))
 
 ;; Adapted from SBCL.




More information about the armedbear-cvs mailing list