

2. Re: comparing Array
JaxNa Aug 9, 2010 10:39 PM (in response to kglad)here are my two array.
when i compare this array that time i got common no.(12,13,17).
12 and 13 is continuous no.
when compare array and i got 12, 13 that time it should be stop this compare and that time i want next no that is (14)
var temItemNo_array:Array = Array(12,13,17,19,20);
var Item_array:Array = Array(12, 13, 14, 15, 16, 17);
Thanks in Advance 
3. Re: comparing Array
kglad Aug 9, 2010 10:46 PM (in response to JaxNa)ok. i understand you're looking for common elements in 2 arrays. i understand you want to check if any common elements are adjacent integers.
if there are 2 common elements that are adjacent integers you want to search for the smallest integer greater than the 2 adjacent ones? does that search have anything to do with elements in either array?

4. Re: comparing Array
JaxNa Aug 9, 2010 10:56 PM (in response to kglad)if there are 2 common elements that are adjacent integers then i want next integer
if 12 & 13 are 2 common element that are adjacent then i want next integer is 14.
one more example
if 17& 18 then i want next integer is 19.
Thanks a lot kglad

5. Re: comparing Array
kglad Aug 9, 2010 11:10 PM (in response to JaxNa)if both arrays contain integers you can use the following function to return an array that meets your criteria:
function findAdjacentIntegers(a1:Array,a2:Array):Array{
var returnA:Array = [];
var t1:Array = a1.slice();
var t2:Array = a2.slice();
t1.sort(18).reverse();
t2.sort(18).reverse();
for(var i=0;i<t1.length;i++){
for(var j=0;j<t2.length;j++){
if(t1[i]==t2[j]){
if(t1[i+1]==t1[i]+1 && t1[i+1]==t2[j+1]){
returnA.push(t1[i]+2);
}
}
}
}
return returnA;
} 

7. Re: comparing Array
kglad Aug 10, 2010 7:37 PM (in response to JaxNa)with your criteria to search for adjacent integers common to both arrays, passing both those arrays to the function i suggested should return 16.
p.s. please mark this thread as answered.