Subject: Re: question on sort
From: Erik Naggum <erik@naggum.net>
Date: 2000/08/01
Newsgroups: comp.lang.lisp
Message-ID: <3174145458945605@naggum.net>

* kp gores <gores@sip.medizin.uni-ulm.de>
| unfortunately they sort only sequences or vectors.

  A sequence is a list or a vector.

| I'd like to sort arrays of whatever dimensions (my array is (* 6)).
| The key should be a element in the array (eg. accessor for column 2).
  
| does a fast and flexible implentation of sort/stable-sort for arbitrary 
| array exist somewhere on the net? 

  Build a vector of the appropriate size with all the keys in it:

(let ((keys (make-array <size>)))
  (dotimes (i <size>)
    (setf (aref keys i) i))
  keys)

  Sort the keys vector, using a :key argument that retrieves the value
  from your array with the value in the keys vector as index.

  If you absolutely have to, rearrange your multidimensional array.
  Otherwise, you just use an indirection through the sorted keys vector.

  I consider the above an example of a pattern in Common Lisp, btw.

#:Erik
-- 
  If this is not what you expected, please alter your expectations.