LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (November 2005)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 2 Nov 2005 10:09:22 +0100
Reply-To:     Spousta Jan <JSpousta@CSAS.CZ>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         Spousta Jan <JSpousta@CSAS.CZ>
Subject:      Re: Sorting algorithm by R Ristow & J Peck - reference
Comments: To: Marta García-Granero <>
Content-Type: text/plain; charset="iso-8859-2"

Yes, true, I've forgotten that Richard used GRADE first. He should be credited as well. Sorry for the confusion. Let's use the name Ristow-Peck. Greetings Jan

-----Original Message----- From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of Marta García-Granero Sent: Wednesday, November 02, 2005 10:00 AM To: SPSSX-L@LISTSERV.UGA.EDU Subject: Re: Sorting algorithm by R Ristow & J Peck - reference

Hi Joe

Perhaps I have confused you a bit with the name ("Sorting algorithm"). I normally call "algorithms" (maybe not correctly) those small pieces of code that perform a task (like sorting, in this case). Whenever I get a really useful piece of code I use a lot, I like to keep track of the authors' names if I'm going to use it in code I write (translating directly, and freely, from a Spanish saying: "I don't like to adorn myself with feathers that aren't mine"). Previously I used a slow and rather complex sorting method.

(See: for the complete exchange of mails, including my original inefficient sorting algorithm).

I gave that snippet of code the name of Ristow/Peck algorithm because it was Richard Ristow who gave the first version of the code (see: ) but Jon Peck modified it a bit after I found that sometimes it didn't work as it was supposed to (see my mail: and Jon's reply: )

As a matter of fact, I also modified the code, because the version I used in the "Trimmed means syntax" you mention sorts just one column, not more than one, but the original idea was Richard's and Jon's, therefore the name.

If you want an explanation on how GRADE works, I think that Richard's was really good. Quoting from his mail:


[Marta jogged my memory on this one:

"AFAIK, MATRIX doesn't have sorting commands. A trick to avoid sorting the data: COMPUTE order=GRADE(A(:,2)) will create a vector (order) with the position of every data in the second column of matrix A."

I think that GRADE is meant as the sorting command for MATRIX: don't return the sorted array; return the index vector that *will* sort the array. (This is one of the 'footprints' that make me think that MATRIX was influenced by the programming language APL, which handled sorting the same way.) It has its points; for example, you can sort the rows of an array by a key vector that's in a different array.

It's somewhat buried in the documentation, but MATRIX (like APL) allows a vector as an array index, applying the elements of the vector individually to give a vector (or array) result. That's what it takes to use a 'grade' index vector easily. I think this is how the developers expected you'd sort a matrix...]


I hope I clarified everything.

Marta Garcia-Granero

JH> In a recent post (10/07/2005, "Re: Trimmed means in SPSS" by Marta JH> Garcia Granero), reference was made to a sorting algorithm by R. JH> Ristow and J. Peck, used in a MATRIX program to create an ordered JH> array, using the statement "COMPUTE y(GRADE(nsdata))=nsdata." JH> Does anyone have a reference to documentation for this algorithm, or JH> the SPSS code?

Back to: Top of message | Previous page | Main SPSSX-L page