src/project/WorkingSetSort.js
function register(command, compareFn, events) {
        var commandID = "";

        if (!command || !compareFn) {
            console.log("Attempting to register a Sort method with a missing required parameter: command or compare function");
            return;
        }
        if (typeof command === "string") {
            commandID = command;
        } else {
            commandID = command.getID();
        }

        if (_sorts[commandID]) {
            console.log("Attempting to register an already-registered Sort method: " + command);
            return;
        }

        // Adds ".sort" to the end of each event to make them specific for the automatic sort.
        if (events) {
            events = events.split(" ");
            events.forEach(function (event, index) {
                events[index] = events[index].trim() + ".sort";
            });
            events = events.join(" ");
        }

        var sort = new Sort(commandID, compareFn, events);
        _sorts[commandID] = sort;
        return sort;
    }
function register(command, compareFn, events) {
        var commandID = "";

        if (!command || !compareFn) {
            console.log("Attempting to register a Sort method with a missing required parameter: command or compare function");
            return;
        }
        if (typeof command === "string") {
            commandID = command;
        } else {
            commandID = command.getID();
        }

        if (_sorts[commandID]) {
            console.log("Attempting to register an already-registered Sort method: " + command);
            return;
        }

        // Adds ".sort" to the end of each event to make them specific for the automatic sort.
        if (events) {
            events = events.split(" ");
            events.forEach(function (event, index) {
                events[index] = events[index].trim() + ".sort";
            });
            events = events.join(" ");
        }

        var sort = new Sort(commandID, compareFn, events);
        _sorts[commandID] = sort;
        return sort;
    }
function register ( command , compareFn , events ) { var commandID = "" ; if ( ! command || ! compareFn ) { console . log ( "Attempting to register a Sort method with a missing required parameter: command or compare function" ) ; return ; } if ( typeof command === "string" ) { commandID = command ; } else { commandID = command . getID ( ) ; } if ( _sorts [ commandID ] ) { console . log ( "Attempting to register an already-registered Sort method: " + command ) ; return ; } // Adds ".sort" to the end of each event to make them specific for the automatic sort. if ( events ) { events = events . split ( " " ) ; events . forEach ( function ( event , index ) { events [ index ] = events [ index ] . trim ( ) + ".sort" ; } ) ; events = events . join ( " " ) ; } var sort = new Sort ( commandID , compareFn , events ) ; _sorts [ commandID ] = sort ; return sort ; }
Registers a working set sort method.
@param {(string|Command)} command A command ID or a command object
@param {function(File, File): number} compareFn The function that
will be used inside JavaScript's sort function. The return a value
should be >0 (sort a to a lower index than b), =0 (leaves a and b
unchanged with respect to each other) or <0 (sort b to a lower index
than a) and must always returns the same value when given a specific
pair of elements a and b as its two arguments. Documentation at:
https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/sort
@param {?string} events One or more space-separated event types that
DocumentManger uses. Each event passed will trigger the automatic
sort. If no events are passed, the automatic sort will be disabled
for that sort method.
@return {?Sort}
Registers a working set sort method .