]> git.mxchange.org Git - flightgear.git/commitdiff
sort entries alphabetically (consistent with property browser)
authormfranz <mfranz>
Sat, 27 Oct 2007 21:28:56 +0000 (21:28 +0000)
committermfranz <mfranz>
Sat, 27 Oct 2007 21:28:56 +0000 (21:28 +0000)
src/Network/httpd.cxx

index cdc4dc3dcbc38615c6452c67723c661a111979ca..700a8c0fbda803a15b370dec78337795adcece33 100644 (file)
@@ -31,6 +31,7 @@
 
 #include <simgear/compiler.h>
 
+#include <algorithm>           // sort()
 #include <stdlib.h>            // atoi() atof()
 
 #include STL_STRING
@@ -83,6 +84,15 @@ bool FGHttpd::close() {
 }
 
 
+class CompareNodes {
+public:
+    bool operator() (const SGPropertyNode_ptr a, const SGPropertyNode_ptr b) const {
+        int r = strcmp(a->getName(), b->getName());
+        return r ? r < 0 : a->getIndex() < b->getIndex();
+    }
+};
+
+
 // Handle http GET requests
 void HttpdChannel::foundTerminator (void) {
     
@@ -193,8 +203,15 @@ void HttpdChannel::foundTerminator (void) {
             response += "\"</H3>";
             response += getTerminator();
 
-            for (int i = 0; i < node->nChildren(); i++) {
-                SGPropertyNode *child = node->getChild(i);
+
+            vector<SGPropertyNode_ptr> children;
+            for (int i = 0; i < node->nChildren(); i++)
+                children.push_back(node->getChild(i));
+            std::sort(children.begin(), children.end(), CompareNodes());
+
+            vector<SGPropertyNode_ptr>::iterator it, end = children.end();
+            for (it = children.begin(); it != end; ++it) {
+                SGPropertyNode *child = *it;
                 string name = child->getDisplayName(true);
                 string line = "";
                 if ( child->nChildren() > 0 ) {