Posts

Showing posts from June, 2021

how to check if 2 lists contain same elements in ColdFusion | Coldfusion code to Compare Lists

 Consider there are 2 lists with numeric elements as below: So the code to compare these 2 lists are given below: <cfset list1 = "455,888,234,456,908"> <cfset list2 = "908,234,456,888,455"> <cfset list1 = ListSort(list1,"numeric") > <cfset list2 = ListSort(list2,"numeric") > <cfoutput>sorted list1 #list1#</cfoutput> <br> <cfoutput>sorted list2 #list2#</cfoutput><br> <cfif compareNoCase(list1, list2) EQ 0>     Both Lists have same elements  <cfelse>     Different elements in both lists  </cfif> If the list contains string elements, then the sort type have to be "numberic"