src/operator/data-builder.js
function sortData(dataObj, sortingDetails) {
    const { data, schema } = dataObj;
    let fieldName;
    let sortMeta;
    let fDetails;
    let i = sortingDetails.length - 1;

    for (; i >= 0; i--) {
        fieldName = sortingDetails[i][0];
        sortMeta = sortingDetails[i][1];
        fDetails = fieldInSchema(schema, fieldName);

        if (!fDetails) {
            // eslint-disable-next-line no-continue
            continue;
        }

        if (isCallable(sortMeta)) {
            // eslint-disable-next-line no-loop-func
            mergeSort(data, (a, b) => sortMeta(a[fDetails.index], b[fDetails.index]));
        } else if (isArray(sortMeta)) {
            const groupedData = groupData(data, fDetails.index);
            const sortingFn = sortMeta[sortMeta.length - 1];
            const targetFields = sortMeta.slice(0, sortMeta.length - 1);
            const targetFieldDetails = targetFields.map(f => fieldInSchema(schema, f));

            groupedData.forEach((groupedDatum) => {
                groupedDatum.push(createSortingFnArg(groupedDatum, targetFields, targetFieldDetails));
            });

            mergeSort(groupedData, (a, b) => {
                const m = a[2];
                const n = b[2];
                return sortingFn(m, n);
            });

            // Empty the array
            data.length = 0;
            groupedData.forEach((datum) => {
                data.push(...datum[1]);
            });
        } else {
            sortMeta = String(sortMeta).toLowerCase() === 'desc' ? 'desc' : 'asc';
            mergeSort(data, getSortFn(fDetails.type, sortMeta, fDetails.index));
        }
    }

    dataObj.uids = [];
    data.forEach((value) => {
        dataObj.uids.push(value.pop());
    });
}
function sortData(dataObj, sortingDetails) {
    const { data, schema } = dataObj;
    let fieldName;
    let sortMeta;
    let fDetails;
    let i = sortingDetails.length - 1;

    for (; i >= 0; i--) {
        fieldName = sortingDetails[i][0];
        sortMeta = sortingDetails[i][1];
        fDetails = fieldInSchema(schema, fieldName);

        if (!fDetails) {
            // eslint-disable-next-line no-continue
            continue;
        }

        if (isCallable(sortMeta)) {
            // eslint-disable-next-line no-loop-func
            mergeSort(data, (a, b) => sortMeta(a[fDetails.index], b[fDetails.index]));
        } else if (isArray(sortMeta)) {
            const groupedData = groupData(data, fDetails.index);
            const sortingFn = sortMeta[sortMeta.length - 1];
            const targetFields = sortMeta.slice(0, sortMeta.length - 1);
            const targetFieldDetails = targetFields.map(f => fieldInSchema(schema, f));

            groupedData.forEach((groupedDatum) => {
                groupedDatum.push(createSortingFnArg(groupedDatum, targetFields, targetFieldDetails));
            });

            mergeSort(groupedData, (a, b) => {
                const m = a[2];
                const n = b[2];
                return sortingFn(m, n);
            });

            // Empty the array
            data.length = 0;
            groupedData.forEach((datum) => {
                data.push(...datum[1]);
            });
        } else {
            sortMeta = String(sortMeta).toLowerCase() === 'desc' ? 'desc' : 'asc';
            mergeSort(data, getSortFn(fDetails.type, sortMeta, fDetails.index));
        }
    }

    dataObj.uids = [];
    data.forEach((value) => {
        dataObj.uids.push(value.pop());
    });
}
function sortData ( dataObj , sortingDetails ) { const { data , schema } = dataObj ; let fieldName ; let sortMeta ; let fDetails ; let i = sortingDetails . length - 1 ; for ( ; i >= 0 ; i -- ) { fieldName = sortingDetails [ i ] [ 0 ] ; sortMeta = sortingDetails [ i ] [ 1 ] ; fDetails = fieldInSchema ( schema , fieldName ) ; if ( ! fDetails ) { // eslint-disable-next-line no-continue continue ; } if ( isCallable ( sortMeta ) ) { // eslint-disable-next-line no-loop-func mergeSort ( data , ( a , b ) => sortMeta ( a [ fDetails . index ] , b [ fDetails . index ] ) ) ; } else if ( isArray ( sortMeta ) ) { const groupedData = groupData ( data , fDetails . index ) ; const sortingFn = sortMeta [ sortMeta . length - 1 ] ; const targetFields = sortMeta . slice ( 0 , sortMeta . length - 1 ) ; const targetFieldDetails = targetFields . map ( f => fieldInSchema ( schema , f ) ) ; groupedData . forEach ( ( groupedDatum ) => { groupedDatum . push ( createSortingFnArg ( groupedDatum , targetFields , targetFieldDetails ) ) ; } ) ; mergeSort ( groupedData , ( a , b ) => { const m = a [ 2 ] ; const n = b [ 2 ] ; return sortingFn ( m , n ) ; } ) ; // Empty the array data . length = 0 ; groupedData . forEach ( ( datum ) => { data . push ( ... datum [ 1 ] ) ; } ) ; } else { sortMeta = String ( sortMeta ) . toLowerCase ( ) === 'desc' ? 'desc' : 'asc' ; mergeSort ( data , getSortFn ( fDetails . type , sortMeta , fDetails . index ) ) ; } } dataObj . uids = [ ] ; data . forEach ( ( value ) => { dataObj . uids . push ( value . pop ( ) ) ; } ) ; }
Sorts the data before return in dataBuilder.

@param {Object} dataObj - An object containing the data and schema.
@param {Array} sortingDetails - An array containing the sorting configs.
Sorts the data before return in dataBuilder .