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 );
More Related Contents:
- Substraction two textbox values with jquery [duplicate]
- Get selected value in dropdown list using JavaScript
- Why would a JavaScript variable start with a dollar sign? [duplicate]
- How to avoid ‘cannot read property of undefined’ errors?
- module.exports vs exports in Node.js
- How to check a not-defined variable in JavaScript
- Using HTML5/JavaScript to generate and save a file
- Best way to call an asynchronous function within map?
- How to display data values on Chart.js
- Check whether an array exists in an array of arrays?
- D3 Appending Text to a SVG Rectangle
- Dot and Square Bracket Notation
- jQuery: how to change tag name?
- Best way to store a key=>value array in JavaScript?
- JavaScript parseFloat in Different Cultures
- iframe shimming or ie6 (and below) select z-index bug
- Reference ASP.NET control by ID in JavaScript?
- How to add anchor tags dynamically to a div in Javascript?
- What’s the time complexity of array.splice() in Google Chrome?
- Two components binding Vuejs
- How to fill in form field, and submit, using javascript?
- How can I save information locally in my chrome extension?
- Leaflet marker event fires at wrong time
- Webpack not excluding node_modules
- How to convert array of key–value objects to array of objects with a single property?
- Convert dropdown to selection boxes with color and trigger drop down action
- Count console.log objects
- angular 2 access ng-content within component
- Keeping history of hash/anchor changes in JavaScript
- How to call a function before leaving page with Javascript