void sort()

in lib/src/tree_table.dart [106:140]


  void sort(String key) {
    var comparator = (LogicalRow a, LogicalRow b) {
      if (a.sortable && !b.sortable) {
        return 1;
      } else if (!a.sortable && b.sortable) {
        return -1;
      } else if (!a.sortable && !b.sortable) {
        return a.nonSortablePriority.compareTo(b.nonSortablePriority);
      }

      var d1 = a.data[key];
      var d2 = b.data[key];
      if (d1 == null) d1 = '';
      if (d2 == null) d2 = '';
      if (d1 is num && d2 is num) {
        return d1.compareTo(d2);
      }
      return d2.toString().compareTo(d1.toString());
    };

    // Clear all of the rows in the table because
    // we will be sorting the `logical` rows and then
    // re-add them all.
    tbody.children.clear();
    this._rootNodes.sort(comparator);

    for (var rootNode in this._rootNodes) {
      rootNode.sort(comparator);
    }

    // Re-add the now-sorted rows.
    for (var rootNode in this._rootNodes) {
      rootNode.show();
    }
  }