This is the mail archive of the
cygwin-apps
mailing list for the Cygwin project.
[PATCH setup 2/9] Alphabetically sort options in usage help
- From: Jon Turney <jon dot turney at dronecode dot org dot uk>
- To: cygwin-apps at cygwin dot com
- Cc: Jon Turney <jon dot turney at dronecode dot org dot uk>
- Date: Tue, 6 Jun 2017 12:54:25 +0100
- Subject: [PATCH setup 2/9] Alphabetically sort options in usage help
- Authentication-results: sourceware.org; auth=none
- References: <20170606115432.105020-1-jon.turney@dronecode.org.uk>
---
libgetopt++/src/OptionSet.cc | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/libgetopt++/src/OptionSet.cc b/libgetopt++/src/OptionSet.cc
index bc3f018..82e1253 100644
--- a/libgetopt++/src/OptionSet.cc
+++ b/libgetopt++/src/OptionSet.cc
@@ -314,9 +314,16 @@ OptionSet::Register (Option * anOption)
options.push_back(anOption);
}
+static bool
+comp_long_option(const Option *a, const Option *b)
+{
+ return (a->longOption().compare(b->longOption()) < 0);
+}
+
void
OptionSet::ParameterUsage (ostream &aStream)
{
+ std::sort(options.begin(), options.end(), comp_long_option);
for_each (options.begin(), options.end(), DefaultFormatter (aStream));
}
--
2.12.3