From f553bf2948dc8ece1c9ec98df3efd6ce6cc4e56e Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Mon, 9 Oct 2017 20:05:58 -0700 Subject: [PATCH] Fixing sort. --- lib/utils.nom | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/utils.nom b/lib/utils.nom index 6fbf57a..2e469c5 100644 --- a/lib/utils.nom +++ b/lib/utils.nom @@ -86,6 +86,13 @@ compile [max of %items by %value_expr] to: | local vars = setmetatable({['']=item}, {__index=vars}) | return \(%value_expr as lua) |end) +compile [sort %items] to: "table.sort(\(%items as lua))" +compile [sort %items by %key] to: ".." + |nomsu.utils.sort(\(%items as lua), function(x) + | local ret, vars = nil, {['']=x}; + | \(%key as lua statements) + | return ret + |end) # String utilities compile [nl, newline, line feed, linefeed, lf] to: ".."