I have 2 arrays i want to sort those arrays and compare it
var A = [1,5,8,0,9];
var B = [5,9,0,1,8];
for(i=0;i<A.length;i++)
{
if(A[i] == B[i]){message}else{Fail}
I want to sort those arrays and then compare the values
I have 2 arrays i want to sort those arrays and compare it
var A = [1,5,8,0,9];
var B = [5,9,0,1,8];
for(i=0;i<A.length;i++)
{
if(A[i] == B[i]){message}else{Fail}
I want to sort those arrays and then compare the values
 
    
    You can just call the sort method on an array:
var A = [1, 5, 8, 0, 9];
var B = [5, 9, 0, 1, 8];
A.sort()
B.sort()
for (i = 0; i < A.length; i++) {
  if (A[i] == B[i]) {
    document.write(A[i] + ' and ' + B[i] + ' are identical' + '<br>')
  } else {
    document.write('fail')
  }
} 
    
    You can use the sort() for this . Arary sort() I cant properly understand whats the aim behind the comparison.SO make necessary changes.
var A = [1,5,8,0,9];
A.sort();
var B = [5,9,0,1,8];
B.sort();
for(i=0;i<A.length;i++)
{
     if(A[i] == B[i])
      {
            message
      }
      else 
      {
             Fail
      }
}
