以相反顺序和正常顺序检查数字序列

时间:2018-06-06 19:55:13

标签: coldfusion

我以非常const a = { name : this.matchedData.clientName, date : this.matchedData.jobDate, destination : this.matchedData.address, stateZip : this.matchedData.zipcode }; if (this.matchedData.address2 !== null){ a.apartment : this.matchedData.address2; } 方式将来自jquery的值设为5,4,3,6,7,8,1

我正在尝试检查ColdFusion进行反向检查和正常检查以查看传递的数字是否按顺序进行

我尝试使用unordered功能,但这不符合此目的

喜欢正常:我想确保数字是这样的:List

for reverse:3,4,5,6,7,8它只会到0而不是负

我怎么能这样做,任何想法

1 个答案:

答案 0 :(得分:3)

<cfset inputList = '5,4,3,6,7,8,1' />
<cfset ascList = listSort(inputList, "numeric", "asc") />
<cfset descList = listSort(inputList, "numeric", "desc") />


<cfif (inputList eq ascList) >
  numbers are in ascending sequence
<cfelseif (inputList eq descList) >
  numbers are in descending sequence
<cfelse>
  numbers are not in sequence
</cfif>

文档: https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-functions/functions-l/listsort.html