Sha256: 3cb07e9ab79386137c5e1c37b1fe3e318966320da2af12657a4b9da7b8bcb198
Contents?: true
Size: 649 Bytes
Versions: 80
Compression:
Stored size: 649 Bytes
Contents
/** * Expose `sort`. */ exports = module.exports = sort; /** * Sort `el`'s children with the given `fn(a, b)`. * * @param {Element} el * @param {Function} fn * @api public */ function sort(el, fn) { var arr = [].slice.call(el.children).sort(fn); var frag = document.createDocumentFragment(); for (var i = 0; i < arr.length; i++) { frag.appendChild(arr[i]); } el.appendChild(frag); }; /** * Sort descending. * * @param {Element} el * @param {Function} fn * @api public */ exports.desc = function(el, fn){ sort(el, function(a, b){ return ~fn(a, b) + 1; }); }; /** * Sort ascending. */ exports.asc = sort;
Version data entries
80 entries across 80 versions & 1 rubygems