Revision 37df271b
Von Sven Schöling vor etwa 7 Jahren hinzugefügt
SL/Menu.pm | ||
---|---|---|
119 | 119 |
push @{ $by_parent{ $node->{parent} // '' } //= [] }, $node; |
120 | 120 |
} |
121 | 121 |
|
122 |
# autovivify order in by_parent, so that numerical sorting for entries without order |
|
123 |
# preserves their order and position with respect to entries with order. |
|
124 |
for (values %by_parent) { |
|
125 |
my $last_order = 0; |
|
126 |
for my $node (@$_) { |
|
127 |
if (defined $node->{order} && $node->{order} * 1) { |
|
128 |
$last_order = $node->{order}; |
|
129 |
} else { |
|
130 |
$node->{order} = ++$last_order; |
|
131 |
} |
|
132 |
} |
|
133 |
} |
|
134 |
|
|
122 | 135 |
my $tree = { }; |
123 | 136 |
$self->{by_id}{''} = $tree; |
124 | 137 |
|
Auch abrufbar als: Unified diff
Menu: Order Einträge automatisch Ergänzen, damit Sortierung stabil ist.