I have this two arrays
var refArray = [\'India\',\'Pakistan\',\'Nepal\',\'Bhutan\',\'SreeLanka\',\'Singapore\',\'Thailand\',\'China\',\'Russia\'] var beenThere
Just compare the indices of each element in the refArray using indexOf method.
refArray
indexOf
beenThere.sort(function(a,b){ return refArray.indexOf(a)-refArray.indexOf(b); })