dist/utilify.esm.js
function objectArraySortByValue(arr, map, key) {
        var _this2 = this;

        var reverse = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;

        if (!validateHelpers.isArray(map) || map.length < 1) {
            var compare = function compare(a, b, n) {
                return _this2.getDescendantProp(a, n).toString().localeCompare(_this2.getDescendantProp(b, n).toString(), undefined, { numeric: true });
            };

            return arr.slice().sort(function (a, b) {
                return reverse ? -compare(a, b, key) : compare(a, b, key);
            });
        }

        return arr.slice().sort(function (a, b) {
            var ordered = map.indexOf(_this2.getDescendantProp(a, key).toString()) - map.indexOf(_this2.getDescendantProp(b, key).toString());

            return reverse ? ordered * -1 : ordered;
        });
    }
function objectArraySortByValue(arr, map, key) {
        var _this2 = this;

        var reverse = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;

        if (!validateHelpers.isArray(map) || map.length < 1) {
            var compare = function compare(a, b, n) {
                return _this2.getDescendantProp(a, n).toString().localeCompare(_this2.getDescendantProp(b, n).toString(), undefined, { numeric: true });
            };

            return arr.slice().sort(function (a, b) {
                return reverse ? -compare(a, b, key) : compare(a, b, key);
            });
        }

        return arr.slice().sort(function (a, b) {
            var ordered = map.indexOf(_this2.getDescendantProp(a, key).toString()) - map.indexOf(_this2.getDescendantProp(b, key).toString());

            return reverse ? ordered * -1 : ordered;
        });
    }
function objectArraySortByValue ( arr , map , key ) { var _this2 = this ; var reverse = arguments . length > 3 && arguments [ 3 ] !== undefined ? arguments [ 3 ] : false ; if ( ! validateHelpers . isArray ( map ) || map . length < 1 ) { var compare = function compare ( a , b , n ) { return _this2 . getDescendantProp ( a , n ) . toString ( ) . localeCompare ( _this2 . getDescendantProp ( b , n ) . toString ( ) , undefined , { numeric : true } ) ; } ; return arr . slice ( ) . sort ( function ( a , b ) { return reverse ? - compare ( a , b , key ) : compare ( a , b , key ) ; } ) ; } return arr . slice ( ) . sort ( function ( a , b ) { var ordered = map . indexOf ( _this2 . getDescendantProp ( a , key ) . toString ( ) ) - map . indexOf ( _this2 . getDescendantProp ( b , key ) . toString ( ) ) ; return reverse ? ordered * - 1 : ordered ; } ) ; }
Sorting an array of objects by values

@param  {Array}   [arr]              An Array of objects
@param  {Mix}     [map]              Map to custom order. If value isn't an array with values, will do natural sort
@param  {String}  [key]              Object key to use for sorting (accepts dot notation)
@param  {Boolean} [reverse=false]    Reverse sorting
@returns {Array}                     New object array with sorting values
@example
var mapToSort = ['A', 'B', 'C', 'D', 'E']; // Map to sorting

var obj = [{param: 'D'}, {param: 'A'}, {param: 'E'}, {param: 'C'}, {param: 'B'}];
globalHelpers.objectArraySortByValue(objToSortByValue, mapToSort, 'param');
//=> [{param: 'A'}, {param: 'B'}, {param: 'C'}, {param: 'D'}, {param: 'E'}]

// Deep key
var obj = [{deep: {param: 'D'}}, {deep: {param: 'A'}}, {deep: {param: 'E'}}, {deep: {param: 'C'}}, {deep: {param: 'B'}}];
globalHelpers.objectArraySortByValue(objToSortByValue, mapToSort, 'deep.param');
//=> [{deep: {param: 'A'}}, {deep: {param: 'B'}}, {deep: {param: 'C'}}, {deep: {param: 'D'}}, {deep: {param: 'E'}}]
Sorting an array of objects by values