grouped property

List<List<UDocMarkup>> get grouped

Markups grouped by selection, sorted in reading order.

Implementation

List<List<UDocMarkup>> get grouped {
  final Map<String, List<UDocMarkup>> groups = <String, List<UDocMarkup>>{};
  for (final UDocMarkup markup in _markups) {
    (groups[markup.groupKey] ??= <UDocMarkup>[]).add(markup);
  }
  final List<List<UDocMarkup>> result = groups.values.toList();
  for (final List<UDocMarkup> entries in result) {
    entries.sort(_readingOrder);
  }
  result.sort((List<UDocMarkup> a, List<UDocMarkup> b) => _readingOrder(a.first, b.first));
  return result;
}