One-Line answer.
itemsArray.sort(function(a, b){
return sortingArr.indexOf(a) - sortingArr.indexOf(b);
});
Or even shorter:
itemsArray.sort((a, b) => sortingArr.indexOf(a) - sortingArr.indexOf(b));
Related Contents:
- Extract hostname name from string
- horizontal scrollbar on top and bottom of table
- Request header field Access-Control-Allow-Headers is not allowed by Access-Control-Allow-Headers
- How to reset a form using jQuery with .reset() method
- innerText vs innerHTML vs label vs text vs textContent vs outerText
- Why is arr = [] faster than arr = new Array?
- Get the value of checked checkbox?
- Promise Retry Design Patterns
- OnChange event using React JS for drop down
- removeEventListener on anonymous functions in JavaScript
- Making facebook login work with an Android Webview
- adding custom functions into Array.prototype
- Using querySelector with IDs that are numbers
- How to Implement DOM Data Binding in JavaScript
- What are cookies and sessions, and how do they relate to each other?
- execute function after complete page load [duplicate]
- How do I synchronize the scroll position of two divs?
- Concatenating variables and strings in React
- iterating through object
- Fetching all (javascript) global variables in a page
- Form Submit Execute JavaScript Best Practice? [closed]
- Contains case insensitive
- Can jQuery read/write cookies to a browser?
- Baking transforms into SVG Path Element commands
- Javascript: Call a function after specific time period
- Unsigned Integer in Javascript
- How can I dynamically unload a javascript file?
- Using Bootstrap Modal window as PartialView
- Remove all attributes
- What does href expression do?
- How to call function on child component on parent events
- Disable scrolling in an iPhone web application?
- Javascript – sorting array by multiple criteria
- How to make embedded hasMany relationships work with ember data
- Firefox setting to enable cross domain Ajax request
- Cannot read property ‘onClicked’ of undefined when using chrome.action or chrome.browserAction
- Replace a value if null or undefined in JavaScript
- Running an Express server middleware alongside Nuxt
- How do I measure the execution time of JavaScript code with callbacks?
- jQuery: Check if div with certain class name exists
- Moment Js UTC to Local Time
- Get the content (text) of an URL after Javascript has run with PHP
- google chrome extension :: console.log() from background page?
- Convert long/lat to pixel x/y on a given picture
- JavaScript – add transition between display:none and display:block
- Conditionally set an object property
- Vue converts input[type=number] to a string value
- How to disable minimize, maximize button in the browser?
- xslt, javascript and unescaped html entities
- Scroll / Jump to id without jQuery