Ok I think I have it!! My code:
<cfset results = deserializeJSON(url.data)>
<cfloop collection = '#results#' item = 'itemName' >
<cfset item = results[itemName]>
<cfset vendorList = listSort(structKeyList(item.vendors),"textnocase","ASC")>
<!---NEW LINE--->
<cfloop list= '#vendorList#' index = 'vendorName'>
<h2>#vendorName#</h2>
<ul class="myList">
<cfset productArray = item.vendors[vendorName]>
<cfset productArray = arraySort(productArray)>
<!--- NEW LINE--->
<cfloop array='#productArray#' index = 'productName'>
<li style="margin-left:30px;">#productName#</li>
</cfloop>
</ul>
</cfloop>
</cfloop>
Then I commented out the line: <cfset productArray = arraySort(productArray)>.
Now it seems to sort the Vendors correct and throughout the complete application! Maybe there is way way to sort an array of structs, if this was the issue at all anyway, but obvioulsy there was something it didnt like.
teedoffnewbie wrote:
Now it seems to sort the Vendors correct and throughout the complete application! |
Yes, the vendors are sorted by these lines creating a sorted list of the vendor keys and then looping for that list, rather the the verdor structure itself.
<cfset vendorList = listSort(structKeyList(item.vendors),"textnocase","ASC")>
<cfloop list= '#vendorList#' index = 'vendorName'>
teedoffnewbie wrote: but obvioulsy there was something it didnt like. |
Yes, it did not like the line you commented out, because I did not use the array sort function correctly.
<cfset productArray = arraySort(productArray)>
Should have been:
<cfset testBoolean = arraySort(productArray,"textnocase")>
That I posted in my earlier reply. This line would also sort the products under each vendor.