Highlighted

Error: Parameter validation error for the sort function. The function accepts 1 parameter(s)

Participant ,
Feb 06, 2020

Copy link to clipboard

Copied

I haven't modified the code in a long time, but I receive this error:

Parameter validation error for the sort function. The function accepts 1 parameter(s)

Any ideas?

Here is my code:

<cfoutput>
<CFHTTP  url="http://www.zipcodeapi.com/rest/a3Pk3kJ1EvbCMrGPtI2kFH0u27u3i4heyZzsUBPv7XZDwxI0cHef4QqNOKKocXjx/radius.json/#zipradius#/#radius#/mile" method = "get" result="httpResp">
</cfhttp>

</cfoutput>

<cfset zipCodeJSON='#httpresp.filecontent#'>

<cfset zipCodeStructure=#deserializeJSON(zipCodeJSON)#>
<cfscript>
zipCodeQuery=queryNew("id,city,distance,state,zipCode","Integer,Varchar,Decimal,Varchar,Integer");


for (row=1; row lte arrayLen(zipCodeStructure.zip_codes); row=row+1) 

{
    rowdata=[row,zipCodeStructure.zip_codes[row].city,zipCodeStructure.zip_codes[row]. distance,zipCodeStructure.zip_codes[row].state,zipCodeStructure.zip_codes[row].zip_code];


    queryAddRow(zipCodeQuery,rowdata);
}

zipCodeQuery.sort(zipCodeQuery.findColumn("distance"),true);

</cfscript>

 

Adobe Community Professional
Correct answer by BKBK | Adobe Community Professional

To sort by distance, use the querySort function or query-of-a-query.

<cfscript> 
	sortedZipCodeQuery = querySort(zipCodeQuery, function(e1,e2){
        return compare(e1.distance,e2.distance);
    });
</cfscript> 

<cfquery name="sortedZipCodeQuery" dbtype="query">
    SELECT *
    FROM zipCodeQuery
    ORDER BY distance
</cfquery>

 

TOPICS
Advanced techniques

Views

366

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Error: Parameter validation error for the sort function. The function accepts 1 parameter(s)

Participant ,
Feb 06, 2020

Copy link to clipboard

Copied

I haven't modified the code in a long time, but I receive this error:

Parameter validation error for the sort function. The function accepts 1 parameter(s)

Any ideas?

Here is my code:

<cfoutput>
<CFHTTP  url="http://www.zipcodeapi.com/rest/a3Pk3kJ1EvbCMrGPtI2kFH0u27u3i4heyZzsUBPv7XZDwxI0cHef4QqNOKKocXjx/radius.json/#zipradius#/#radius#/mile" method = "get" result="httpResp">
</cfhttp>

</cfoutput>

<cfset zipCodeJSON='#httpresp.filecontent#'>

<cfset zipCodeStructure=#deserializeJSON(zipCodeJSON)#>
<cfscript>
zipCodeQuery=queryNew("id,city,distance,state,zipCode","Integer,Varchar,Decimal,Varchar,Integer");


for (row=1; row lte arrayLen(zipCodeStructure.zip_codes); row=row+1) 

{
    rowdata=[row,zipCodeStructure.zip_codes[row].city,zipCodeStructure.zip_codes[row]. distance,zipCodeStructure.zip_codes[row].state,zipCodeStructure.zip_codes[row].zip_code];


    queryAddRow(zipCodeQuery,rowdata);
}

zipCodeQuery.sort(zipCodeQuery.findColumn("distance"),true);

</cfscript>

 

Adobe Community Professional
Correct answer by BKBK | Adobe Community Professional

To sort by distance, use the querySort function or query-of-a-query.

<cfscript> 
	sortedZipCodeQuery = querySort(zipCodeQuery, function(e1,e2){
        return compare(e1.distance,e2.distance);
    });
</cfscript> 

<cfquery name="sortedZipCodeQuery" dbtype="query">
    SELECT *
    FROM zipCodeQuery
    ORDER BY distance
</cfquery>

 

TOPICS
Advanced techniques

Views

367

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Feb 06, 2020 0
Adobe Community Professional ,
Feb 06, 2020

Copy link to clipboard

Copied

To sort by distance, use the querySort function or query-of-a-query.

<cfscript> 
	sortedZipCodeQuery = querySort(zipCodeQuery, function(e1,e2){
        return compare(e1.distance,e2.distance);
    });
</cfscript> 

<cfquery name="sortedZipCodeQuery" dbtype="query">
    SELECT *
    FROM zipCodeQuery
    ORDER BY distance
</cfquery>

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 06, 2020 1
BACFL LATEST
Participant ,
Feb 08, 2020

Copy link to clipboard

Copied

@BKBK that did the trick. Many thanks!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 08, 2020 0