Ric,
Unfortunately there isn't a very good way to sort a structure by the all key
values-which I think is what you're trying to do. If you need to sort the
keys alphabetically, you could use the StructKeyList() function with the
ListSort() function to sort the keys.
However, to sort by keys, you'd need to do something like this once your
structure is completed:
1) Create an new array
2) Mask the integer value to a common length, by prepending zeros to the
string (aka "1" becomes "0000001")
3) Next, use ListAppend(key, "|") (or whatever delimiter makes sense) to
append that element's key to the end of the value and store the new value
into a new array position
4) Repeat steps 2 and 4 for all elements in the structure.
5) Now you can use the ArraySort() function to sort the values in any manor
necessary.
6) The first element in the list will be the value of the key, the second
item will be the original key.
Like I said, it's not pretty, but there's not much else you can do. (Well,
I'm sure there are a 1,000 ways to get to the same result, but they'll all
revolve around convert the structure into some other data type...
-Dan
+--------+---------------------------+
| name | Dan G. Switzer, II |
|company | PengoWorks.com |
| www | http://www.pengoworks.com |
| mailto | [EMAIL PROTECTED] |
+--------+---------------------------+
-----Original Message-----
From: Ric Smith [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 26, 2000 2:25 PM
To: [EMAIL PROTECTED]
Subject: sorting a structure
Is there any way to sort a CF Struct like you
can a perl associative array using sort and keys.
I'm basicly reading in a bunch of words and
creating a struct element for each word with
the key being the word. If the key already
exists then I just increment the value of that
element. I then want to order the elements
desc. I guess i could use and array and arraysort.
hmmm.
Any help is appreciated. Thanks.
Ric Smith
----------------------------------------------------------------------------
--
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.
------------------------------------------------------------------------------
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.