From 259d296b144856bb40547d43e6008670a7d9ba5c Mon Sep 17 00:00:00 2001 From: dmiller Date: Fri, 7 Jun 2024 16:34:05 +0000 Subject: [PATCH] Allow outlib.sorted_by_key to specify sort function --- nselib/outlib.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nselib/outlib.lua b/nselib/outlib.lua index 3379256fe..97d1f55a6 100644 --- a/nselib/outlib.lua +++ b/nselib/outlib.lua @@ -32,12 +32,12 @@ local _ENV = {} -- instead. --@param t The table whose data should be used --@return out A table that can be passed to pairs() to get sorted results -function sorted_by_key(t) +function sorted_by_key(t, sortfunc) local out = {} setmetatable(out, { __pairs = function(_) local order = keys(t) - sort(order) + sort(order, sortfunc) return wrap(function() for i,k in ipairs(order) do yield(k, t[k])