+ {
+ size_t n_total_cells = 0;
+ for (size_t j = 0; j < t->n_sections; j++)
+ n_total_cells += hmap_count (&t->sections[j].cells);
+
+ struct ctables_cell **sorted = xnmalloc (n_total_cells, sizeof *sorted);
+ size_t n_sorted = 0;
+ for (size_t j = 0; j < t->n_sections; j++)
+ {
+ const struct ctables_section *s = &t->sections[j];
+ struct ctables_cell *cell;
+ HMAP_FOR_EACH (cell, struct ctables_cell, node, &s->cells)
+ if (!cell->hide)
+ sorted[n_sorted++] = cell;
+ }
+ assert (n_sorted <= n_total_cells);
+ sort (sorted, n_sorted, sizeof *sorted, ctables_cell_compare_leaf_3way,
+ NULL);
+ size_t ids[N_CTDTS];
+ memset (ids, 0, sizeof ids);
+ for (size_t j = 0; j < n_sorted; j++)
+ {
+ struct ctables_cell *cell = sorted[j];
+ for (enum ctables_domain_type dt = 0; dt < N_CTDTS; dt++)
+ {
+ struct ctables_domain *domain = cell->domains[dt];
+ if (!domain->sequence)
+ domain->sequence = ++ids[dt];
+ }
+ }
+
+ free (sorted);
+ }
+