I have a global array
var g = [ \"jack\", \"queen\", \"king\", \"10\", \"ace\",\"7\", \"8\", \"9\"];
and my array
var my =
One possible way:
var g = ['jack', 'queen', 'king', '10', 'ace', '7', '8', '9']; var my = ['9', 'king', '7', 'ace']; my.sort(function(a, b) { return g.indexOf(a) - g.indexOf(b); }); console.log( my );