From 4c9fae4e97d95a9f89d1399a8aeb03051f0fec96 Mon Sep 17 00:00:00 2001 From: Bruce Korb Date: Thu, 14 Aug 2008 06:24:59 -0700 Subject: sort: new option, --sort=version, for version number ordering * src/sort.c [struct keyfield] (version): New member. (usage): Describe --version-sort. (sort_options): Add 'V'. (long_options): Add "version-sort". (CHECK_TABLE, _ct_, SORT_TABLE, _st_): Define new macros. (check_args, sort_args, sort_types): Use these new macros in declarations. (ARGMATCH_VERIFY): Remove use. No longer needed. (compare_version): New function. (key_compare): Add a case. (check_ordering_compatibility): Handle new type. (main): Likewise. Reformat two expressions for readability. * tests/misc/sort-version: new test file * tests/Makefile.am: add it to the list * doc/coreutils.texi (sort invocation): Document it. * NEWS: Mention the new feature. --- doc/coreutils.texi | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'doc') diff --git a/doc/coreutils.texi b/doc/coreutils.texi index cfd283d80..229154281 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -3733,6 +3733,16 @@ Neither a leading @samp{+} nor exponential notation is recognized. To compare such strings numerically, use the @option{--general-numeric-sort} (@option{-g}) option. +@item -V +@itemx --version-sort +@opindex -V +@opindex --version-sort +@cindex version number sort +@vindex LC_NUMERIC +Sort per @code{strverscmp(3)}. This is a normal string comparison, except +that embedded decimal numbers are sorted by numeric value +(see @option{--numeric-sort} above). + @item -r @itemx --reverse @opindex -r -- cgit v1.2.3-54-g00ecf