1 var copyArray = require('./_copyArray'),
2 isIndex = require('./_isIndex');
4 /* Built-in method references for those with the same name as other `lodash` methods. */
5 var nativeMin = Math.min;
8 * Reorder `array` according to the specified indexes where the element at
9 * the first index is assigned as the first element, the element at
10 * the second index is assigned as the second element, and so on.
13 * @param {Array} array The array to reorder.
14 * @param {Array} indexes The arranged array indexes.
15 * @returns {Array} Returns `array`.
17 function reorder(array, indexes) {
18 var arrLength = array.length,
19 length = nativeMin(indexes.length, arrLength),
20 oldArray = copyArray(array);
23 var index = indexes[length];
24 array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
29 module.exports = reorder;