diff --git a/generateZonefiles.py b/generateZonefiles.py index d0607f5..11722a7 100644 --- a/generateZonefiles.py +++ b/generateZonefiles.py @@ -99,6 +99,8 @@ def sanitize(entry): result.append(new_entry) + result.sort(key=lambda k: k['data']) + return result diff --git a/zone_template.j2 b/zone_template.j2 index 87ac3a9..1233027 100644 --- a/zone_template.j2 +++ b/zone_template.j2 @@ -9,7 +9,7 @@ $TTL {{ ttl }} {{ zone }}. {{ ttl }} IN NS {{ ns }} {% endfor %} {%- if mailserver | length > 0 %} -{% for mailserver, weight in mailserver.items() -%} +{% for mailserver, weight in mailserver | dictsort -%} {{ zone }}. {{ ttl }} IN MX {{ weight }} {{ mailserver }} {% endfor -%} {%- endif %}