src/js/table/TableStore.js
function(colIndex, direction) {
        this.sortColIndex = colIndex;
        this.cols[colIndex].sortDirection = direction;

        var defaultDirection = this.cols[colIndex].defaultSortDirection;
        var dataType = this.cols[this.sortColIndex].dataType;
        var key = this.cols[this.sortColIndex].dataProperty;

        if (this.pagination) {
            this.resetPagination();
        }
        /* eslint-disable complexity */
        this.data.sort(function(a, b) {
            var first = a[key];
            var second = b[key];

            // undefined/null values are sorted to the end of the table when the sort direction is equal to the default
            // sort direction, and to the top of the table when the sort direction is opposite of default
            if (first === null || first === undefined) {
                if (second === null || second === undefined) {
                    return 0;
                }
                return defaultDirection === direction ? 1 : -1;
            }
            if (second === null || second === undefined) {
                return defaultDirection === direction ? -1 : 1;
            }

            if (dataType === 'string') {
                first = first.toLowerCase();
                second = second.toLowerCase();
            }

            if (first > second) {
                return direction === 'ascending' ? 1 : -1;
            }
            if (first < second) {
                return direction === 'ascending' ? -1 : 1;
            }
            // a must be equal to b
            return 0;
        });
        /* eslint-enable complexity */
    }
function(colIndex, direction) {
        this.sortColIndex = colIndex;
        this.cols[colIndex].sortDirection = direction;

        var defaultDirection = this.cols[colIndex].defaultSortDirection;
        var dataType = this.cols[this.sortColIndex].dataType;
        var key = this.cols[this.sortColIndex].dataProperty;

        if (this.pagination) {
            this.resetPagination();
        }
        /* eslint-disable complexity */
        this.data.sort(function(a, b) {
            var first = a[key];
            var second = b[key];

            // undefined/null values are sorted to the end of the table when the sort direction is equal to the default
            // sort direction, and to the top of the table when the sort direction is opposite of default
            if (first === null || first === undefined) {
                if (second === null || second === undefined) {
                    return 0;
                }
                return defaultDirection === direction ? 1 : -1;
            }
            if (second === null || second === undefined) {
                return defaultDirection === direction ? -1 : 1;
            }

            if (dataType === 'string') {
                first = first.toLowerCase();
                second = second.toLowerCase();
            }

            if (first > second) {
                return direction === 'ascending' ? 1 : -1;
            }
            if (first < second) {
                return direction === 'ascending' ? -1 : 1;
            }
            // a must be equal to b
            return 0;
        });
        /* eslint-enable complexity */
    }
Sorts the array of data for the Table based on the sort column index and the direction.
@param {Number} colIndex - The index of the table column that is to sorted.
@param {String} direction - The direction to sort (ascending or descending).