Sorting 2 variables: one ascending, one descending Moneo Posting Freak Posts: 1,956 Threads: 65 Joined: Jun 2003 11-12-2004, 08:55 AM NEO: The XOR solution is exactly what I was hinting at. Another gold star for you, Neo. Here's a piece of code from an old program of mine which does exactly this.Code:```complement:             'Complement each key byte for DESCENDING   for zz = 1 to len(k\$)       mid\$(k\$,zz,1) = chr\$( asc(mid\$(k\$,zz,1)) XOR 255 )   next zz RETURN     '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>```An XOR of any byte with 255 will produce the complement of the original byte value. This is known as the one's complement, which means that every 1 becomes a 0, and every 0 becomes a 1. MEG: Thanks for letting TOOH have it with both barrels. Yes I'm posting from Mexico City. Timezone-wise that's the same time as Chicago. I don't post at strange times, usually at night when I get home from work. About the sayings. The Turkish one I got from my first mother-in-law who was a Greek born in Istanbul. She quoted this saying all the time as being Turkish. Let's keep in mind that this lady was born in 1900, so the saying could be outdated. The one about singing out of the same hymm book comes from an American saying that a person who is not 100% mentally, is "not singing out of the same hymm book". This saying too may be outdated since I'm 66 years old and can't remember how long ago I heard it. It is real, however. I love old sayings. A programmer friend of mine called Mick, who was born in Texas, used to quote sayings from his mother all the time. My favorite was: "Im so tired, I feel like I've been ironing all day with a cold ironÂ¨. You've got to hear it with a Texas drawl. ***** Moneo Posting Freak Posts: 1,956 Threads: 65 Joined: Jun 2003 11-14-2004, 05:20 AM Quote:I suppose if the sorting column were alphanumeric, you would be better off "subtracting" it from a string of CHR\$(255)'s. For each character "x" in the string, replace it with CHR\$(255-ASC("x")) in the sortkey. *peace* Meg. MEG: Forgive me. In my last post I was so excited with the fact the Neo came up with the XOR solution, that I neglected to acknowledge your equally elegant solution with has exactly the same effect using arithmetic instead of the XOR bit-wise logic. I consider that both you and Neo are the co-winners of the challenge by demonstrating that manipulation of the sort key can solve an otherwise sticky sorting problem. Hurrah to you both. Neo Posting Freak Posts: 1,845 Threads: 44 Joined: Aug 2002 11-15-2004, 01:54 PM Thanks very much Moneo I almost feel special... but there's one lady who's more special: Meg! Congratulations on co-winning and a Hurray! You have a great algorithmic thinking mind... Btw, 255 - A is exactly the same as A XOR 255. Licentia Member Posts: 57 Threads: 9 Joined: Jun 2004 11-17-2004, 08:27 AM I can see that what I was asking was not a simple thing. Yikes. I'll have to wait awhile before my mind can grasp all that. But I found that program wasn't really useful to me so I'll forget about it for now and challenge myself another day. Moneo Posting Freak Posts: 1,956 Threads: 65 Joined: Jun 2003 11-21-2004, 07:37 AM Neo, Don't even think about it --- you are special. Neo Posting Freak Posts: 1,845 Threads: 44 Joined: Aug 2002 11-21-2004, 04:40 PM Quote:Neo, Don't even think about it --- you are special. Nah... thanks Moneo Ok ok, I'm special But I still don't refrain from my previous statement, so: I may be special, then Meg is more special *I'm collecting gold stars* « Next Oldest | Next Newest »