Moneo, Meg:
Whatever type of data you select or whatever size it is, there always is an upper bound to the data. Whether it's alphanumerical, or numerical, respectively the upperbounds are ascii 255 and 9. Using this, we can convert any type of data from it's ascending form to it's descending form, or vice-versa, depending on the situation.
About all the credit and such, I think Meg gets most credit for the 100 - Age formula because he posted a solution before I was going to post it...
The only difference between our programs (which I was going to post the same time until I saw Meg's program!
) was that I used 99 - Age instead of 100 - Age. Oh well.
Here's some code to convert a string to it's ascending/descending version:
[syntax="QBasic"]FUNCTION Convert$ (ThaString AS STRING)
retstr$ = ""
FOR I = 1 TO LEN(ThaString)
retstr$ = retstr$ + CHR$(ASC(MID$(ThaString, I, 1)) XOR 255)
NEXT I
Convert$ = retstr$
END FUNCTION[/syntax]
So basically, what you do when you want something mixed ascending/descending, is look at which field(s) are easiest converted, and convert them. Then you sort ascending/descending, then convert these fields back. It is also possible to calculate the conversions on-the-fly.
Also, if you want to sort on other fields first, you just recombine the string to make it possible without extra IFs. Suppose we first wanted ascending on age, then on name, we would use:
Code:
SortKey$ = Age$ + PersonName$
Oh well, I'm just more or less repeating what Meg already said (she was first again! :roll
.