about summary refs log tree commit diff
path: root/src/libexpr/primops.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-01-25T15·06+0100
committerEelco Dolstra <edolstra@gmail.com>2017-01-26T19·40+0100
commit54801ed6ad4e0ea8faa67b0b4ba10debeb824d3b (patch)
tree3e8f94aad34c4b1011cf77b1f6527d3f09f2c502 /src/libexpr/primops.cc
parentb1f001538e41a4f28e315baeede93a8fe70d6d62 (diff)
Bindings: Add a method for iterating in lexicographically sorted order
Diffstat (limited to 'src/libexpr/primops.cc')
-rw-r--r--src/libexpr/primops.cc9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index 59623874c3f5..d8dbedcaf89e 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -998,12 +998,9 @@ static void prim_attrNames(EvalState & state, const Pos & pos, Value * * args, V
 
     state.mkList(v, args[0]->attrs->size());
 
-    unsigned int n = 0;
-    for (auto & i : *args[0]->attrs)
-        mkString(*(v.listElems()[n++] = state.allocValue()), i.name);
-
-    std::sort(v.listElems(), v.listElems() + n,
-        [](Value * v1, Value * v2) { return strcmp(v1->string.s, v2->string.s) < 0; });
+    size_t n = 0;
+    for (auto & i : args[0]->attrs->lexicographicOrder())
+        mkString(*(v.listElems()[n++] = state.allocValue()), i->name);
 }