SOT aligning multiple lists
I have 6 alphabetical lists, CFML structure key lists but I don't think that matters. These 6 lists have many common keys with each having a few differences. I want to display a table with each list in its own column. I would like it to sort such that common keys align together in the same row. But if no common key then skip that row for that list. Maybe a diagram would clarify this. ListA ListB ListC 1 1 1 2 2 3 3 4 5 5 The trouble is there is no master list to drive this from. I just can not get my sleep deprived, aging mind to conceive of a way to create this display from six arbitrary lists. TIA Ian ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326712 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: SOT aligning multiple lists
One solution would be to create a master list first, and then loop over it, detecting which lists contain the value and indicating as such. Another would be to iterate over all three lists concurrently, and at each iteration check and see which list (or lists) contains the lowest unprocessed value, use that for the current row, and then mark all instances of that value as processed. The former is probably simpler to implement, but requires two passes, an extra parallel data structure, and a whole bunch of exists-in-collection checks. As such, it's probably somewhat less performant, but you'd have to do some tests to confirm that, as the difference is probably trivial with small list sizes and counts. cheers, barneyb On Mon, Sep 28, 2009 at 12:30 PM, Ian Skinner h...@ilsweb.com wrote: I have 6 alphabetical lists, CFML structure key lists but I don't think that matters. These 6 lists have many common keys with each having a few differences. I want to display a table with each list in its own column. I would like it to sort such that common keys align together in the same row. But if no common key then skip that row for that list. Maybe a diagram would clarify this. ListA ListB ListC 1 1 1 2 2 3 3 4 5 5 The trouble is there is no master list to drive this from. I just can not get my sleep deprived, aging mind to conceive of a way to create this display from six arbitrary lists. TIA Ian -- Barney Boisvert bboisv...@gmail.com h ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326713 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: SOT aligning multiple lists
Well I came up with one way. |!--- loop over and create master list of unique values by creating a temp structure --- cfset masterList = structNew() cfloop collection=#positions# item=type cfloop list=#structKeyList(positions[type])# index=item cfset masterList[item] = /cfloop /cfloop !--- extract master list --- cfset masterList = listSort(structKeyList(masterList),textNoCase) cfoutput table border=1 tr cfloop list=#listSort(structKeyList(positions),'textNoCase')# index=type th#type#/th /cfloop /tr !--- loop over master list to display table of all elements cfloop list=#masterList# index=key tr !--- loop over each of the contributint lists --- cfloop collection=#positions# item=type !--- if the current list has the current item, display item --- tdcfif structKeyExists(positions[type],key)#key#/cfif/td /cfloop /tr /cfloop /table /cfoutput | ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326715 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4