MichaelRed,
Let me address some of the issues that you have with my solution as well as touch upon some of your suggestions.
1) You said,
"First, the change in the order of magnitude of the random number is irrelevant to the process."
Actually, the order of magnitude here is very important. It is used to ensure that each row gets a unique number. Remember that each row gets its own random number assigned to it and ideally, these random numbers should be as unique as possible in the set of rows to ensure that all of the rows are "unsorted". The sort algorithm sorts on the random number column and only the random number column, so if you picked an integer number between 0 and 1 (i.e. only two choices) the chances of the final results be truly random is not as great as if a larger range of number was used.
For Example, given the dataset as follows . . .
Code:
Questions Low Range Sort High Range Sort
Code:
Question 1 1 34212
Question 2 1 21093
Question 3 0 54210
Question 4 0 10293
The low range sort would be sorted as follows . . .
Question 3
Question 4
Question 1
Question 2
While the High Range Sort would be sorted as
Question 4
Question 2
Question 1
Question 3
You can see that the first would still follow some of the basic order while the second option would have a much better chance of breaking away from the original order. This may not be real obvious with only 4 question (which is all I used form my example), but add alot more question and run the app several times and statistically speaking, the higher the order of magnitude, the better the randomization will be.
2) You said,
Second, the SORT is a bit to SIMPLISTIC.
YES IT IS! I will be the first to agree with you on this. As a matter of fact, if you go back and look at my code comments as well as the text in my post, you will see that I state the very same thing! The routine that I used at work used an ADO recordset and the ADO Sort method to sort on the randomized field so I did not have to write any sorting code. However, the question here was for an array, not a recordset, So I quick threw together a VERY BASIC sort for a VERY BASIC example of the idea. The demo code here was not intended to be an example of ideal sorting algorithms, but rather a demo of how to unsort an array.
3) You said,
Last (and probably least), this exercise BEGS (to me) for the use of an (albiet simplistic) UDT, which obviates the need for at least the replacement of the original array of strings.
Yes , I would agree with you here to and I even thought of doing it . . . however, as I said before, the idea here was not to make the code elaborate, but rather to show the basic idea. There are many ways to expand on this and some of your ideas are great. However, adding too much to this demo would detract from it original purpose. Yes I could have stored the question in a database (and in the real world I would have and do - I help develop computerized testing applications that are used for Certification Tests - such as MS certification) but once again for a quick demo, it was easier hardcode them into the application.
Anyway, I have said more than my 2 cents on this, but I did feel a need to address some of your points. - Jeff Marler B-)