# HG changeset patch # User Kim Alvefur # Date 1575147381 -3600 # Node ID 5267f12b038df464c3a768baf9292431e396e5f4 # Parent 658b759a1f7abe226eb31f84540d97a4bb9e6c1d mod_admin_telnet: Sort hosts Groups by domain in DNS hierarchy order or something. Why not split on '.' you ask? Well becasue that's not what I typed here. Also "[^.]" is longer than "%P". diff -r 658b759a1f7a -r 5267f12b038d plugins/mod_admin_telnet.lua --- a/plugins/mod_admin_telnet.lua Sat Nov 30 19:34:40 2019 +0100 +++ b/plugins/mod_admin_telnet.lua Sat Nov 30 21:56:21 2019 +0100 @@ -964,11 +964,15 @@ return hostmanager.deactivate(hostname, reason); end +local function compare_hosts(a, b) + return a:gsub("%P", string.reverse):reverse() < b:gsub("%P", string.reverse):reverse(); +end + function def_env.host:list() local print = self.session.print; local i = 0; local type; - for host, host_session in iterators.sorted_pairs(prosody.hosts) do + for host, host_session in iterators.sorted_pairs(prosody.hosts, compare_hosts) do i = i + 1; type = host_session.type; if type == "local" then