lib/SortByKey.js
function objectSortByKey(data, key, reverse) {
    let keys = Object.keys(data);
    keys.sort((a, b) => {
        const aw = data[a][key] !== undefined ? parseInt(data[a][key], 10) : 0;
        const bw = data[b][key] !== undefined ? parseInt(data[b][key], 10) : 0;
        if (aw === bw) {
            return 0;
        }

        return reverse !== true && aw < bw ? -1 : 1;
    });

    keys.forEach((key) => {
        const value = data[key];
        delete data[key];
        data[key] = value;
    });
}
function objectSortByKey(data, key, reverse) {
    let keys = Object.keys(data);
    keys.sort((a, b) => {
        const aw = data[a][key] !== undefined ? parseInt(data[a][key], 10) : 0;
        const bw = data[b][key] !== undefined ? parseInt(data[b][key], 10) : 0;
        if (aw === bw) {
            return 0;
        }

        return reverse !== true && aw < bw ? -1 : 1;
    });

    keys.forEach((key) => {
        const value = data[key];
        delete data[key];
        data[key] = value;
    });
}
function objectSortByKey ( data , key , reverse ) { let keys = Object . keys ( data ) ; keys . sort ( ( a , b ) => { const aw = data [ a ] [ key ] !== undefined ? parseInt ( data [ a ] [ key ] , 10 ) : 0 ; const bw = data [ b ] [ key ] !== undefined ? parseInt ( data [ b ] [ key ] , 10 ) : 0 ; if ( aw === bw ) { return 0 ; } return reverse !== true && aw < bw ? - 1 : 1 ; } ) ; keys . forEach ( ( key ) => { const value = data [ key ] ; delete data [ key ] ; data [ key ] = value ; } ) ; }
Sort an object by the provided key.

@param {Array} data The object to sort.
@param {String} key The key to use for sorting.
@param {boolean} [reverse=false] Reverse the order.
Sort an object by the provided key .