src/basis/data/dataset/Slice.js
function(rule, orderDesc){
    rule = basis.getter(rule || $true);
    orderDesc = !!orderDesc;

    if (this.rule != rule || this.orderDesc != orderDesc)
    {
      var oldRule = this.rule;
      var oldOrderDesc = this.orderDesc;

      // rebuild index only if rule changing
      if (this.rule != rule)
      {
        var index = this.index_;

        for (var i = 0; i < index.length; i++)
          index[i].value = nanToUndefined(rule(index[i].object));

        index.sort(sliceIndexSort);

        this.rule = rule;
      }

      // set new values
      this.orderDesc = orderDesc;
      this.rule = rule;
      this.emit_ruleChanged(oldRule, oldOrderDesc);

      return this.applyRule();
    }
  }
function(rule, orderDesc){
    rule = basis.getter(rule || $true);
    orderDesc = !!orderDesc;

    if (this.rule != rule || this.orderDesc != orderDesc)
    {
      var oldRule = this.rule;
      var oldOrderDesc = this.orderDesc;

      // rebuild index only if rule changing
      if (this.rule != rule)
      {
        var index = this.index_;

        for (var i = 0; i < index.length; i++)
          index[i].value = nanToUndefined(rule(index[i].object));

        index.sort(sliceIndexSort);

        this.rule = rule;
      }

      // set new values
      this.orderDesc = orderDesc;
      this.rule = rule;
      this.emit_ruleChanged(oldRule, oldOrderDesc);

      return this.applyRule();
    }
  }
function ( rule , orderDesc ) { rule = basis . getter ( rule || $true ) ; orderDesc = ! ! orderDesc ; if ( this . rule != rule || this . orderDesc != orderDesc ) { var oldRule = this . rule ; var oldOrderDesc = this . orderDesc ; // rebuild index only if rule changing if ( this . rule != rule ) { var index = this . index_ ; for ( var i = 0 ; i < index . length ; i ++ ) index [ i ] . value = nanToUndefined ( rule ( index [ i ] . object ) ) ; index . sort ( sliceIndexSort ) ; this . rule = rule ; } // set new values this . orderDesc = orderDesc ; this . rule = rule ; this . emit_ruleChanged ( oldRule , oldOrderDesc ) ; return this . applyRule ( ) ; } }
Set new rule and order.
@param {function(item:basis.data.Object):*|string} rule
@param {boolean} orderDesc
@return {object} Delta of member changes.
Set new rule and order .