code: function sortByDepth(arr, descending) {
      arr.sort(function (a, b) {
          return dom(descending ? b : a).parents().length - dom(descending ? a : b).parents().length;
      });
  }
docs: Sorts array of DOM elements by its depth in DOM tree.
  @param {HTMLElement[]} arr - array to sort.
  @param {boolean} descending - order of sort.