fill_config.py: sort foreach items numerically, not alphabetically
Make sure that BTS 11 doesn't get sorted between BTS 1 and 2, because osmo-bsc
requires the BTS to be configured in numerical order.
Also makes sense as foreach loop ordering in general.
Change-Id: Ib06052fd71def3d4c869ee9b3dc4d02ba06267af
diff --git a/net/fill_config.py b/net/fill_config.py
index d99d9f6..557381f 100755
--- a/net/fill_config.py
+++ b/net/fill_config.py
@@ -166,19 +166,19 @@
item_m = item_re.match(item)
if not item_m:
continue
- items.add((item_m.group(1), item_m.group(2)))
+ items.add((int(item_m.group(2)), item_m.group(1)))
items = sorted(list(items))
expanded = [before_block]
- for item, nr in items:
+ for nr, item in items:
expanded_block = foreach_block
while True:
expanded_block_was = expanded_block
expanded_block = expanded_block.replace('${%sn_' % arg, '${%s_' % item)
- expanded_block = expanded_block.replace('${%sn}' % arg, nr)
+ expanded_block = expanded_block.replace('${%sn}' % arg, str(nr))
expanded_block = replace_vars(expanded_block, tmpl_dir, tmpl_src, local_config)
if expanded_block_was == expanded_block: