Lines Matching refs:sort

1 @c GNU Version-sort ordering documentation
14 @node Version sort ordering
15 @chapter Version sort ordering
19 @node Version sort overview
20 @section Version sort overview
22 @dfn{Version sort} puts items such as file names and lines of
32 Lexicographic sort: Version Sort:
40 Version sort functionality in GNU Coreutils is available in the @samp{ls -v},
41 @samp{ls --sort=version}, @samp{sort -V}, and
42 @samp{sort --version-sort} commands.
46 @node Using version sort in GNU Coreutils
47 @subsection Using version sort in GNU Coreutils
49 Two GNU Coreutils programs use version sort: @command{ls} and @command{sort}.
51 To list files in version sort order, use @command{ls}
52 with the @option{-v} or @option{--sort=version} option:
55 default sort: version sort:
66 To sort text files in version sort order, use @command{sort} with
67 the @option{-V} or @option{--version-sort} option:
77 lexicographic order: version sort order:
79 $ sort input $ sort -V input
86 To sort a specific field in a file, use @option{-k/--key} with
96 $ sort -k 2bV,2 input2
103 @node Version sort and natural sort
104 @subsection Version sort and natural sort
106 In GNU Coreutils, the name @dfn{version sort} was chosen because it is based
114 (see @ref{Differences from Debian version sort}).
118 @uref{https://en.wikipedia.org/wiki/Natural_sort_order,natural sort}.
121 @node Variations in version sort order
122 @subsection Variations in version sort order
124 Currently there is no standard for version sort.
128 own ordering algorithm and call it ``version sort'', ``natural sort'',
131 See @ref{Other version/natural sort implementations} for many examples of
134 If you find a bug in the Coreutils implementation of version-sort, please
135 report it. @xref{Reporting version sort bugs}.
138 @node Version sort implementation
139 @section Version sort implementation
141 GNU Coreutils version sort is based on the ``upstream version''
146 This section describes the GNU Coreutils sort ordering rules.
149 sort}) describes some differences between GNU Coreutils
150 and Debian version sort.
153 @node Version-sort ordering rules
154 @subsection Version-sort ordering rules
156 The version sort ordering rules are:
177 ASCII letters sort before other bytes.
206 Consider the version-sort comparison of two file names:
245 Result when using sort:
251 $ sort -V input3
256 See @ref{Differences from Debian version sort} for
260 @node Version sort is not the same as numeric sort
261 @subsection Version sort is not the same as numeric sort
277 $ sort -n input4 $ sort -V input4
287 Numeric sort (@samp{sort -n}) treats the entire string as a single numeric
292 Version sort (@samp{sort -V}) first breaks down the string into digit and
294 example in @ref{Version-sort ordering rules}).
311 @node Version sort punctuation
312 @subsection Version sort punctuation
325 Based on the version-sort ordering rules, the strings are broken down
360 $ sort -V input5
369 Rule 2.B.a says letters sort before non-letters
376 $ sort -V input6
407 $ sort -V input7
437 @node Version sort ignores locale
438 @subsection Version sort ignores locale
440 In version sort, Unicode characters are compared byte-by-byte according
462 @samp{a} and @samp{z} are letters, and sort before
469 @node Differences from Debian version sort
470 @section Differences from Debian version sort
472 GNU Coreutils version sort differs slightly from the
509 letters. @xref{Version sort punctuation}.
512 a version string with hyphen will sort before similar strings without
532 @node Special priority in GNU Coreutils version sort
533 @subsection Special priority in GNU Coreutils version sort
535 In GNU Coreutils version sort, the following items have
536 special priority and sort before all other strings (listed in order):
545 @item Strings starting with dot (@samp{.}) sort before
552 $ printf '%s\n' a "" b "." c ".." ".d20" ".d3" | sort -V
567 For @samp{sort -V} these priorities might seem arbitrary. However,
568 because the sorting code is shared between the @command{ls} and @command{sort}
574 GNU Coreutils version sort implements specialized handling
595 without them, using version sort (see @ref{Version-sort ordering
597 Coreutils version sort}).
605 and the entire strings are compared using version sort.
706 As empty strings sort before non-empty strings, the result is @samp{hello-8}
718 For @samp{sort -V} these priorities might seem arbitrary. However,
719 because the sorting code is shared between the @command{ls} and @command{sort}
772 $ compver abb ab-cd 2>/dev/null $ printf 'abb\nab-cd\n' | sort -V
784 $ printf '%s\n' hello-8.txt hello-8.2.txt | sort -V
790 @node Advanced version sort topics
794 @node Reporting version sort bugs
795 @subsection Reporting version sort bugs
797 If you suspect a bug in GNU Coreutils version sort (i.e., in the
798 output of @samp{ls -v} or @samp{sort -V}), please first check the following:
808 sections in @ref{Differences from Debian version sort}? If it is,
824 @node Other version/natural sort implementations
825 @subsection Other version/natural sort implementations
828 version/natural sort, each with its own rules. Some examples are:
857 NodeJS's @uref{https://www.npmjs.com/package/natural-sort,natural-sort package}.
862 glob modifier} @samp{*(n)} will expand to files in natural sort order.
871 not identical to GNU Coreutils version sort ordering).