sort method

Future<void> sort(
  1. int index,
  2. dynamic context
)

Implementation

Future<void> sort(final int index, context) async {
  busy = true;

  int i = 0;
  TableHeaderCellModel? model;
  while ((model = getHeaderCell(i)) != null) {
    if (i == index) {
      model = getHeaderCell(index);
      if (model != null) {
        model.sorted = true;
        model.sortAscending = !model.sortAscending;
        model.isSorting = true;
      }


      TRANSFORM.Sort sort = TRANSFORM.Sort(null,
          field: model?.sort,
          type: model?.sortType,
          ascending: model?.sortAscending,
          casesensitive: false);

      await sort.apply(data);
    } else
      model?.sorted = false;
    i = i + 1;
  }

  // clear rows
  this.rows.forEach((_,row) => row.dispose());
  this.rows.clear();

  // Notify Listeners of Change
  notifyListeners('list', null);

  busy = false;
}