RE: Anybody have a UDF that will sort a structure on it's values?
> However, that is technically not ordering the structure; merely > processing elements inside the structure in a specific order. By there > very nature structures are unordered. In most cases, I doubt it makes a > difference. > Nor should a structure be ordered. In CFMX, a structure is a hash table, so it is meant for O(1) value lookups based on known keys. If you need something that functions similar to a structure i.e. implements the Map interface, but need the values to be stored in a specific order then you need a class that implements the SortedMap interface; TreeMap is one such class and provides a constructor to turning Maps into TreeMaps. -Matt ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Anybody have a UDF that will sort a structure on it's values?
But surely you can then loop thru the keys returned as an array by structSort(), using it as an index for your structure? > -Original Message- > From: Jon Block [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, 7 January 2003 10:45 a.m. > To: CF-Talk > Subject: RE: Anybody have a UDF that will sort a structure on it's > values? > > > Exactly - I need the values to spit out like records in a > record set. When I > use structSort, I lose the values and get an index like > 1,2,3,4 rather than > my original strucure values. I guess I'll just create a tag > that magically > turns the structure into a custom recordset object which will > simplify my > life. Given all the things I'm trying to do in this page > load, this will be > the best way to go for me. > > Thanks, > Jon > > -Original Message- > From: Jeffry Houser [mailto:[EMAIL PROTECTED]] > Sent: Monday, January 06, 2003 4:47 PM > To: CF-Talk > Subject: Re: Anybody have a UDF that will sort a structure on it's > values? > > > Do you mean that the values of the structure are integers, > or the keys of > the structure are integers? > If the latter, then StructSort, as someone else had mentioned, would > probably do it. It will return an array. Then you'll have > to loop over > the array, sending the current array value as the key to the > structure in > your processing code. > > However, that is technically not ordering the structure; merely > processing elements inside the structure in a specific order. > By there > very nature structures are unordered. In most cases, I doubt > it makes a > difference. > > I might ask the question if you should you be using an > array instead of a > structure? > > > At 04:26 PM 1/6/2003 -0500, you wrote: > > >I want to loop over a structure that I have but in a > specific order. The > >values of my structure are integers so I want to start with > the highest > >number first and go from there decending. > > > >Anybody have a good UDF for this? > > > >Thanks, > >Jon > > > > > > ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting. Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Anybody have a UDF that will sort a structure on it's values?
Hope I get the syntax correct... keyArray = StructSort(theStruct); for(itr = 1; itr lte ArrayLen(keyArray); itr = itr + 1) WriteOutput(keyArray[itr] & ":" & theStruct[keyArray[itr]]); Matt Liotta President & CEO Montara Software, Inc. http://www.montarasoftware.com/ 888-408-0900 x901 > -Original Message- > From: Jon Block [mailto:[EMAIL PROTECTED]] > Sent: Monday, January 06, 2003 4:45 PM > To: CF-Talk > Subject: RE: Anybody have a UDF that will sort a structure on it's values? > > Exactly - I need the values to spit out like records in a record set. When > I > use structSort, I lose the values and get an index like 1,2,3,4 rather > than > my original strucure values. I guess I'll just create a tag that magically > turns the structure into a custom recordset object which will simplify my > life. Given all the things I'm trying to do in this page load, this will > be > the best way to go for me. > > Thanks, > Jon > > -Original Message- > From: Jeffry Houser [mailto:[EMAIL PROTECTED]] > Sent: Monday, January 06, 2003 4:47 PM > To: CF-Talk > Subject: Re: Anybody have a UDF that will sort a structure on it's > values? > > > Do you mean that the values of the structure are integers, or the keys > of > the structure are integers? > If the latter, then StructSort, as someone else had mentioned, would > probably do it. It will return an array. Then you'll have to loop over > the array, sending the current array value as the key to the structure in > your processing code. > > However, that is technically not ordering the structure; merely > processing elements inside the structure in a specific order. By there > very nature structures are unordered. In most cases, I doubt it makes a > difference. > > I might ask the question if you should you be using an array instead of > a > structure? > > > At 04:26 PM 1/6/2003 -0500, you wrote: > > >I want to loop over a structure that I have but in a specific order. The > >values of my structure are integers so I want to start with the highest > >number first and go from there decending. > > > >Anybody have a good UDF for this? > > > >Thanks, > >Jon > > > > > > ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Anybody have a UDF that will sort a structure on it's values?
Exactly - I need the values to spit out like records in a record set. When I use structSort, I lose the values and get an index like 1,2,3,4 rather than my original strucure values. I guess I'll just create a tag that magically turns the structure into a custom recordset object which will simplify my life. Given all the things I'm trying to do in this page load, this will be the best way to go for me. Thanks, Jon -Original Message- From: Jeffry Houser [mailto:[EMAIL PROTECTED]] Sent: Monday, January 06, 2003 4:47 PM To: CF-Talk Subject: Re: Anybody have a UDF that will sort a structure on it's values? Do you mean that the values of the structure are integers, or the keys of the structure are integers? If the latter, then StructSort, as someone else had mentioned, would probably do it. It will return an array. Then you'll have to loop over the array, sending the current array value as the key to the structure in your processing code. However, that is technically not ordering the structure; merely processing elements inside the structure in a specific order. By there very nature structures are unordered. In most cases, I doubt it makes a difference. I might ask the question if you should you be using an array instead of a structure? At 04:26 PM 1/6/2003 -0500, you wrote: >I want to loop over a structure that I have but in a specific order. The >values of my structure are integers so I want to start with the highest >number first and go from there decending. > >Anybody have a good UDF for this? > >Thanks, >Jon > > ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Anybody have a UDF that will sort a structure on it's values?
Do you mean that the values of the structure are integers, or the keys of the structure are integers? If the latter, then StructSort, as someone else had mentioned, would probably do it. It will return an array. Then you'll have to loop over the array, sending the current array value as the key to the structure in your processing code. However, that is technically not ordering the structure; merely processing elements inside the structure in a specific order. By there very nature structures are unordered. In most cases, I doubt it makes a difference. I might ask the question if you should you be using an array instead of a structure? At 04:26 PM 1/6/2003 -0500, you wrote: >I want to loop over a structure that I have but in a specific order. The >values of my structure are integers so I want to start with the highest >number first and go from there decending. > >Anybody have a good UDF for this? > >Thanks, >Jon > > ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Anybody have a UDF that will sort a structure on it's values?
Have you looked at structSort()? > -Original Message- > From: Jon Block [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, 7 January 2003 10:27 a.m. > To: CF-Talk > Subject: Anybody have a UDF that will sort a structure on it's values? > > > I want to loop over a structure that I have but in a specific > order. The > values of my structure are integers so I want to start with > the highest > number first and go from there decending. > > Anybody have a good UDF for this? > > Thanks, > Jon > > ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Get the mailserver that powers this list at http://www.coolfusion.com Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4