YUI.add("recordset-sort",function(s,t){var i=s.ArraySort.compare,e=s.Lang.isValue;function o(t,e,r){o.superclass.constructor.apply(this,arguments)}s.mix(o,{NS:"sort",NAME:"recordsetSort",ATTRS:{lastSortProperties:{value:{field:undefined,desc:!0,sorter:undefined},validator:function(t){return e(t.field)&&e(t.desc)&&e(t.sorter)}},defaultSorter:{value:function(t,e,r,s){r=i(t.getValue(r),e.getValue(r),s);return 0===r?i(t.get("id"),e.get("id"),s):r}},isSorted:{value:!1}}}),s.extend(o,s.Plugin.Base,{initializer:function(t){var e=this,r=this.get("host");this.publish("sort",{defaultFn:s.bind("_defSortFn",this)}),this.on("sort",function(){e.set("isSorted",!0)}),this.onHostEvent("add",function(){e.set("isSorted",!1)},r),this.onHostEvent("update",function(){e.set("isSorted",!1)},r)},destructor:function(t){},_defSortFn:function(r){this.get("host")._items.sort(function(t,e){return r.sorter(t,e,r.field,r.desc)}),this.set("lastSortProperties",r)},sort:function(t,e,r){this.fire("sort",{field:t,desc:e,sorter:r||this.get("defaultSorter")})},resort:function(){var t=this.get("lastSortProperties");this.fire("sort",{field:t.field,desc:t.desc,sorter:t.sorter||this.get("defaultSorter")})},reverse:function(){this.get("host")._items.reverse()},flip:function(){var t=this.get("lastSortProperties");e(t.field)&&this.fire("sort",{field:t.field,desc:!t.desc,sorter:t.sorter||this.get("defaultSorter")})}}),s.namespace("Plugin").RecordsetSort=o},"patched-v3.18.3",{requires:["arraysort","recordset-base","plugin"]});