aboutsummaryrefslogtreecommitdiff
path: root/lib/utils.nom
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2017-10-09 20:05:58 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2017-10-09 20:05:58 -0700
commitf553bf2948dc8ece1c9ec98df3efd6ce6cc4e56e (patch)
treec597d8f9470c7428971e775e44e5af1d3fbdbb56 /lib/utils.nom
parent782383975cb9ff7ebfd2f8c88d9fd5518e2e11e2 (diff)
Fixing sort.
Diffstat (limited to 'lib/utils.nom')
-rw-r--r--lib/utils.nom7
1 files changed, 7 insertions, 0 deletions
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: ".."