Annotation of src/usr.bin/sort/sort.1, Revision 1.55
1.55 ! schwarze 1: .\" $OpenBSD: sort.1,v 1.54 2015/04/05 14:20:22 millert Exp $
1.1 millert 2: .\"
3: .\" Copyright (c) 1991, 1993
4: .\" The Regents of the University of California. All rights reserved.
5: .\"
6: .\" This code is derived from software contributed to Berkeley by
7: .\" the Institute of Electrical and Electronics Engineers, Inc.
8: .\"
9: .\" Redistribution and use in source and binary forms, with or without
10: .\" modification, are permitted provided that the following conditions
11: .\" are met:
12: .\" 1. Redistributions of source code must retain the above copyright
13: .\" notice, this list of conditions and the following disclaimer.
14: .\" 2. Redistributions in binary form must reproduce the above copyright
15: .\" notice, this list of conditions and the following disclaimer in the
16: .\" documentation and/or other materials provided with the distribution.
1.20 millert 17: .\" 3. Neither the name of the University nor the names of its contributors
1.1 millert 18: .\" may be used to endorse or promote products derived from this software
19: .\" without specific prior written permission.
20: .\"
21: .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22: .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23: .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24: .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25: .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26: .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27: .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28: .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29: .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30: .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31: .\" SUCH DAMAGE.
32: .\"
33: .\" @(#)sort.1 8.1 (Berkeley) 6/6/93
34: .\"
1.53 millert 35: .Dd $Mdocdate: April 5 2015 $
1.1 millert 36: .Dt SORT 1
37: .Os
38: .Sh NAME
39: .Nm sort
1.41 millert 40: .Nd sort, merge, or sequence check text and binary files
1.1 millert 41: .Sh SYNOPSIS
42: .Nm sort
1.43 jmc 43: .Op Fl bCcdfgHhiMmnRrsuVz
1.42 jmc 44: .Op Fl k Ar field1 Ns Op , Ns Ar field2
1.23 jmc 45: .Op Fl o Ar output
1.42 jmc 46: .Op Fl S Ar size
1.1 millert 47: .Op Fl T Ar dir
1.23 jmc 48: .Op Fl t Ar char
1.34 sobrado 49: .Op Ar
1.1 millert 50: .Sh DESCRIPTION
51: The
1.8 aaron 52: .Nm
1.41 millert 53: utility sorts text and binary files by lines.
54: A line is a record separated from the subsequent record by a
1.55 ! schwarze 55: newline (default) or NUL \'\\0\' character
! 56: .Po
! 57: .Fl z
! 58: option
! 59: .Pc .
1.41 millert 60: A record can contain any printable or unprintable characters.
61: Comparisons are based on one or more sort keys extracted from
62: each line of input, and are performed lexicographically,
63: according to the current locale's collating rules and the
64: specified command-line options that can tune the actual
65: sorting behavior.
1.8 aaron 66: By default, if keys are not given,
67: .Nm
1.41 millert 68: uses entire lines for comparison.
1.1 millert 69: .Pp
1.49 jmc 70: If no
71: .Ar file
72: is specified, or if
73: .Ar file
74: is
75: .Sq - ,
76: the standard input is used.
77: .Pp
1.7 aaron 78: The options are as follows:
1.21 jmc 79: .Bl -tag -width Ds
1.41 millert 80: .It Fl C, Fl Fl check=silent|quiet
1.35 schwarze 81: Check that the single input file is sorted.
82: If it is, exit 0; if it's not, exit 1.
83: In either case, produce no output.
1.41 millert 84: .It Fl c, Fl Fl check
1.35 schwarze 85: Like
86: .Fl C ,
1.37 jmc 87: but additionally write a message to
1.35 schwarze 88: .Em stderr
89: if the input file is not sorted.
1.41 millert 90: .It Fl m , Fl Fl merge
1.1 millert 91: Merge only; the input files are assumed to be pre-sorted.
1.41 millert 92: If they are not sorted, the output order is undefined.
93: .It Fl o Ar output , Fl Fl output Ns = Ns Ar output
94: Write the output to the
1.1 millert 95: .Ar output
1.41 millert 96: file instead of the standard output.
1.12 aaron 97: This file can be the same as one of the input files.
1.42 jmc 98: .It Fl S Ar size , Fl Fl buffer-size Ns = Ns Ar size
1.41 millert 99: Use a memory buffer no larger than
100: .Ar size .
101: The modifiers %, b, K, M, G, T, P, E, Z, and Y can be used.
102: If no memory limit is specified,
103: .Nm
104: may use up to about 90% of available memory.
105: If the input is too big to fit into the memory buffer,
106: temporary files are used.
1.42 jmc 107: .It Fl s
108: Stable sort; maintains the original record order of records that have
1.50 jmc 109: an equal key.
1.42 jmc 110: This is a non-standard feature, but it is widely accepted and used.
1.41 millert 111: .It Fl T Ar dir , Fl Fl temporary-directory Ns = Ns Ar dir
112: Store temporary files in the directory
113: .Ar dir .
114: The default path is the value of the environment variable
1.1 millert 115: .Ev TMPDIR
116: or
117: .Pa /var/tmp
118: if
119: .Ev TMPDIR
1.41 millert 120: is not defined.
121: .It Fl u , Fl Fl unique
1.12 aaron 122: Unique: suppress all but one in each set of lines having equal keys.
1.41 millert 123: This option implies a stable sort (see below).
124: If used with
1.35 schwarze 125: .Fl C
126: or
1.41 millert 127: .Fl c ,
128: .Nm
129: also checks that there are no lines with duplicate keys.
1.38 jmc 130: .El
131: .Pp
1.1 millert 132: The following options override the default ordering rules.
1.37 jmc 133: If ordering options appear before the first
134: .Fl k
135: option, they apply globally to all sort keys.
1.1 millert 136: When attached to a specific key (see
137: .Fl k ) ,
1.41 millert 138: the ordering options override all global ordering options for that key.
1.37 jmc 139: Note that the ordering options intended to apply globally should not
140: appear after
141: .Fl k
142: or results may be unexpected.
1.1 millert 143: .Bl -tag -width indent
1.41 millert 144: .It Fl d , Fl Fl dictionary-order
145: Consider only blank spaces and alphanumeric characters in comparisons.
146: .It Fl f , Fl Fl ignore-case
147: Consider all lowercase characters that have uppercase
1.12 aaron 148: equivalents to be the same for purposes of comparison.
1.41 millert 149: .It Fl g, Fl Fl general-numeric-sort, Fl Fl sort=general-numeric
150: Sort by general numerical value.
151: As opposed to
152: .Fl n ,
1.50 jmc 153: this option handles general floating points.
154: It has a more
155: permissive format than that allowed by
156: .Fl n
1.41 millert 157: but it has a significant performance drawback.
158: .It Fl h, Fl Fl human-numeric-sort, Fl Fl sort=human-numeric
159: Sort by numerical value, but take into account the SI suffix,
160: if present.
161: Sorts first by numeric sign (negative, zero, or
162: positive); then by SI suffix (either empty, or `k' or `K', or one
163: of `MGTPEZY', in that order); and finally by numeric value.
164: The SI suffix must immediately follow the number.
165: For example, '12345K' sorts before '1M', because M is "larger" than K.
166: This sort option is useful for sorting the output of a single invocation
167: of 'df' command with
168: .Fl h
169: or
170: .Fl H
171: options (human-readable).
172: .It Fl i , Fl Fl ignore-nonprinting
1.1 millert 173: Ignore all non-printable characters.
1.41 millert 174: .It Fl M, Fl Fl month-sort, Fl Fl sort=month
175: Sort by month abbreviations.
176: Unknown strings are considered smaller than valid month names.
177: .It Fl n , Fl Fl numeric-sort, Fl Fl sort=numeric
1.12 aaron 178: An initial numeric string, consisting of optional blank space, optional
179: minus sign, and zero or more digits (including decimal point)
1.1 millert 180: .\" with
181: .\" optional radix character and thousands
182: .\" separator
183: .\" (as defined in the current locale),
184: is sorted by arithmetic value.
1.41 millert 185: Leading blank characters are ignored.
186: .It Fl R, Fl Fl random-sort, Fl Fl sort=random
187: Sort lines in random order.
188: This is a random permutation of the inputs with the exception that
189: equal keys sort together.
190: It is implemented by hashing the input keys and sorting the hash values.
191: The hash function is randomized with data from
1.47 jmc 192: .Xr arc4random_buf 3 ,
1.41 millert 193: or by file content if one is specified via
194: .Fl Fl random-source .
195: If multiple sort fields are specified,
196: the same random hash function is used for all of them.
197: .It Fl r , Fl Fl reverse
198: Sort in reverse order.
199: .It Fl V, Fl Fl version-sort
200: Sort version numbers.
201: The input lines are treated as file names in form
202: PREFIX VERSION SUFFIX, where SUFFIX matches the regular expression
203: "(\.([A-Za-z~][A-Za-z0-9~]*)?)*".
204: The files are compared by their prefixes and versions (leading
205: zeros are ignored in version numbers, see example below).
206: If an input string does not match the pattern, then it is compared
207: using the byte compare function.
208: All string comparisons are performed in the C locale.
1.44 jmc 209: .Pp
210: For example:
211: .Bd -literal -offset indent
212: $ ls sort* | sort -V
213: sort-1.022.tgz
214: sort-1.23.tgz
215: sort-1.23.1.tgz
216: sort-1.024.tgz
217: sort-1.024.003.
218: sort-1.024.003.tgz
219: sort-1.024.07.tgz
220: sort-1.024.009.tgz
221: .Ed
1.1 millert 222: .El
223: .Pp
1.12 aaron 224: The treatment of field separators can be altered using these options:
1.1 millert 225: .Bl -tag -width indent
1.41 millert 226: .It Fl b , Fl Fl ignore-leading-blanks
227: Ignore leading blank space when determining the start
228: and end of a restricted sort key (see
229: .Fl k ) .
230: If
1.1 millert 231: .Fl b
1.41 millert 232: is specified before the first
1.1 millert 233: .Fl k
1.41 millert 234: option, it applies globally to all key specifications.
235: Otherwise,
1.1 millert 236: .Fl b
1.41 millert 237: can be attached independently to each
1.1 millert 238: .Ar field
1.41 millert 239: argument of the key specifications.
1.53 millert 240: Note that
241: .Fl b
242: should not appear after
243: .Fl k ,
244: and that it has no effect unless key fields are specified.
1.41 millert 245: .It Xo
1.42 jmc 246: .Fl k Ar field1 Ns Op , Ns Ar field2 ,
247: .Fl Fl key Ns = Ns Ar field1 Ns Op , Ns Ar field2
1.41 millert 248: .Xc
249: Define a restricted sort key that has the starting position
250: .Ar field1 ,
251: and optional ending position
252: .Ar field2
253: of a key field.
254: The
255: .Fl k
256: option may be specified multiple times,
257: in which case subsequent keys are compared after earlier keys compare equal.
258: The
1.1 millert 259: .Fl k
1.41 millert 260: option replaces the obsolete options
261: .Cm \(pl Ns Ar pos1
262: and
263: .Fl Ns Ar pos2 ,
264: but the old notation is also supported.
265: .It Fl t Ar char , Fl Fl field-separator Ns = Ns Ar char
266: Use
1.3 aaron 267: .Ar char
1.41 millert 268: as the field separator character.
1.8 aaron 269: The initial
1.1 millert 270: .Ar char
1.12 aaron 271: is not considered to be part of a field when determining key offsets.
1.1 millert 272: Each occurrence of
273: .Ar char
274: is significant (for example,
275: .Dq Ar charchar
276: delimits an empty field).
277: If
278: .Fl t
1.6 pjanzen 279: is not specified, the default field separator is a sequence of
280: blank-space characters, and consecutive blank spaces do
281: .Em not
282: delimit an empty field; further, the initial blank space
283: .Em is
284: considered part of a field when determining key offsets.
1.41 millert 285: To use NUL as field separator, use
286: .Fl t
287: \'\\0\'.
288: .It Fl z , Fl Fl zero-terminated
289: Use NUL as the record separator.
290: By default, records in the files are expected to be separated by
291: the newline characters.
292: With this option, NUL (\'\\0\') is used as the record separator character.
1.37 jmc 293: .El
294: .Pp
1.41 millert 295: Other options:
1.37 jmc 296: .Bl -tag -width indent
1.41 millert 297: .It Fl Fl batch-size Ns = Ns Ar num
298: Specify maximum number of files that can be opened by
299: .Nm
300: at once.
301: This option affects behavior when having many input files or using
302: temporary files.
1.51 millert 303: The minimum value is 2.
1.41 millert 304: The default value is 16.
305: .It Fl Fl compress-program Ns = Ns Ar program
306: Use
307: .Ar program
308: to compress temporary files.
309: When invoked with no arguments,
310: .Ar program
311: must compress standard input to standard output.
312: When called with the
313: .Fl d
314: option, it must decompress standard input to standard output.
315: If
316: .Ar program
317: fails,
318: .Nm
319: will exit with an error.
1.37 jmc 320: The
1.41 millert 321: .Xr compress 1
322: and
323: .Xr gzip 1
324: utilities meet these requirements.
325: .It Fl Fl debug
326: Print some extra information about the sorting process to the
327: standard output.
328: .It Fl Fl files0-from Ns = Ns Ar filename
329: Take the input file list from the file
1.44 jmc 330: .Ar filename .
1.41 millert 331: The file names must be separated by NUL
332: (like the output produced by the command
333: .Dq find ... -print0 ) .
1.49 jmc 334: .It Fl Fl heapsort
335: Try to use heap sort, if the sort specifications allow.
336: This sort algorithm cannot be used with
337: .Fl u
338: and
339: .Fl s .
340: .It Fl Fl help
341: Print the help text and exit.
342: .It Fl Fl mergesort , Fl H
1.41 millert 343: Use mergesort.
344: This is a universal algorithm that can always be used,
345: but it is not always the fastest.
1.49 jmc 346: .It Fl Fl mmap
347: Try to use file memory mapping system call.
348: It may increase speed in some cases.
1.41 millert 349: .It Fl Fl qsort
350: Try to use quick sort, if the sort specifications allow.
351: This sort algorithm cannot be used with
352: .Fl u
353: and
354: .Fl s .
1.49 jmc 355: .It Fl Fl radixsort
356: Try to use radix sort, if the sort specifications allow.
357: The radix sort can only be used for trivial locales (C and POSIX),
358: and it cannot be used for numeric or month sort.
359: Radix sort is very fast and stable.
360: .It Fl Fl random-source Ns = Ns Ar filename
361: For random sort, the contents of
362: .Ar filename
363: are used as the source of the
364: .Sq seed
365: data for the hash function.
366: Two invocations of random sort with the same seed data will use
367: produce the same result if the input is also identical.
368: By default, the
369: .Xr arc4random_buf 3
370: function is used instead.
371: .It Fl Fl version
372: Print the version and exit.
1.3 aaron 373: .El
1.1 millert 374: .Pp
1.12 aaron 375: A field is defined as a maximal sequence of characters other than the
1.6 pjanzen 376: field separator and record separator
377: .Pq newline by default .
378: Initial blank spaces are included in the field unless
379: .Fl b
380: has been specified;
381: the first blank space of a sequence of blank spaces acts as the field
382: separator and is included in the field (unless
383: .Fl t
384: is specified).
385: For example, by default all blank spaces at the beginning of a line are
386: considered to be part of the first field.
1.1 millert 387: .Pp
1.12 aaron 388: Fields are specified by the
1.45 jmc 389: .Fl k Ar field1 Ns Op , Ns Ar field2
1.41 millert 390: option.
391: If
1.1 millert 392: .Ar field2
1.41 millert 393: is missing, the end of the key defaults to the end of the line.
1.1 millert 394: .Pp
395: The arguments
396: .Ar field1
397: and
398: .Ar field2
399: have the form
400: .Em m.n
1.6 pjanzen 401: .Em (m,n > 0)
1.41 millert 402: and can be followed by one or more of the modifiers
1.6 pjanzen 403: .Cm b , d , f , i ,
1.41 millert 404: .Cm n , g , M
1.6 pjanzen 405: and
406: .Cm r ,
407: which correspond to the options discussed above.
1.41 millert 408: When
409: .Cm b
410: is specified it applies only to
411: .Ar field1
412: or
413: .Ar field2
414: where it is specified while the rest of the modifiers
415: apply to the whole key field regardless if they are
416: specified only with
417: .Ar field1
418: or
419: .Ar field2
420: or both.
1.1 millert 421: A
422: .Ar field1
423: position specified by
424: .Em m.n
425: is interpreted as the
426: .Em n Ns th
1.6 pjanzen 427: character from the beginning of the
1.1 millert 428: .Em m Ns th
429: field.
430: A missing
431: .Em \&.n
432: in
433: .Ar field1
434: means
435: .Ql \&.1 ,
436: indicating the first character of the
437: .Em m Ns th
1.12 aaron 438: field; if the
1.1 millert 439: .Fl b
440: option is in effect,
441: .Em n
1.12 aaron 442: is counted from the first non-blank character in the
1.1 millert 443: .Em m Ns th
444: field;
445: .Em m Ns \&.1b
1.12 aaron 446: refers to the first non-blank character in the
1.1 millert 447: .Em m Ns th
448: field.
1.6 pjanzen 449: .No 1\&. Ns Em n
450: refers to the
451: .Em n Ns th
452: character from the beginning of the line;
453: if
454: .Em n
455: is greater than the length of the line, the field is taken to be empty.
1.1 millert 456: .Pp
1.41 millert 457: .Em n Ns th
458: positions are always counted from the field beginning, even if the field
459: is shorter than the number of specified positions.
460: Thus, the key can really start from a position in a subsequent field.
461: .Pp
1.1 millert 462: A
463: .Ar field2
464: position specified by
465: .Em m.n
1.12 aaron 466: is interpreted as the
1.1 millert 467: .Em n Ns th
1.41 millert 468: character (including separators) from the beginning of the
1.1 millert 469: .Em m Ns th
470: field.
471: A missing
472: .Em \&.n
1.5 aaron 473: indicates the last character of the
1.1 millert 474: .Em m Ns th
475: field;
1.5 aaron 476: .Em m
1.1 millert 477: = \&0
478: designates the end of a line.
479: Thus the option
480: .Fl k Ar v.x,w.y
1.41 millert 481: is synonymous with the obsolete option
1.1 millert 482: .Cm \(pl Ns Ar v-\&1.x-\&1
483: .Fl Ns Ar w-\&1.y ;
484: when
485: .Em y
486: is omitted,
487: .Fl k Ar v.x,w
488: is synonymous with
1.5 aaron 489: .Cm \(pl Ns Ar v-\&1.x-\&1
1.19 tdeval 490: .Fl Ns Ar w\&.0 .
1.41 millert 491: The obsolete
1.1 millert 492: .Cm \(pl Ns Ar pos1
493: .Fl Ns Ar pos2
494: option is still supported, except for
1.3 aaron 495: .Fl Ns Ar w\&.0b ,
1.1 millert 496: which has no
497: .Fl k
498: equivalent.
499: .Sh ENVIRONMENT
500: .Bl -tag -width Fl
1.46 jmc 501: .It Ev GNUSORT_NUMERIC_COMPATIBILITY
502: If defined
503: .Fl t
504: will not override the locale numeric symbols, that is, thousand
505: separators and decimal separators.
506: By default, if we specify
507: .Fl t
508: with the same symbol as the thousand separator or decimal point,
509: the symbol will be treated as the field separator.
1.50 jmc 510: Older behavior was less definite: the symbol was treated as both field
1.46 jmc 511: separator and numeric separator, simultaneously.
512: This environment variable enables the old behavior.
513: .It Ev LANG
514: Used as a last resort to determine different kinds of locale-specific
1.50 jmc 515: behavior if neither the respective environment variable nor
1.46 jmc 516: .Ev LC_ALL
517: are set.
518: .It Ev LC_ALL
1.50 jmc 519: Locale settings that override all of the other locale settings.
1.46 jmc 520: This environment variable can be used to set all these settings
521: to the same value at once.
1.41 millert 522: .It Ev LC_COLLATE
523: Locale settings to be used to determine the collation for
524: sorting records.
525: .It Ev LC_CTYPE
526: Locale settings to be used to case conversion and classification
527: of characters, that is, which characters are considered
528: whitespaces, etc.
529: .It Ev LC_MESSAGES
530: Locale settings that determine the language of output messages
531: that
532: .Nm
533: prints out.
534: .It Ev LC_NUMERIC
535: Locale settings that determine the number format used in numeric sort.
536: .It Ev LC_TIME
537: Locale settings that determine the month format used in month sort.
1.1 millert 538: .It Ev TMPDIR
1.41 millert 539: Path to the directory in which temporary files will be stored.
1.3 aaron 540: Note that
1.1 millert 541: .Ev TMPDIR
542: may be overridden by the
543: .Fl T
544: option.
1.11 aaron 545: .El
1.1 millert 546: .Sh FILES
547: .Bl -tag -width Pa -compact
1.41 millert 548: .It Pa /var/tmp/.bsdsort.PID.*
549: Temporary files.
1.39 jmc 550: .El
551: .Sh EXIT STATUS
552: The
553: .Nm
554: utility exits with one of the following values:
555: .Pp
556: .Bl -tag -width Ds -offset indent -compact
557: .It 0
1.41 millert 558: Successfully sorted the input files or if used with
559: .Fl C
560: or
561: .Fl c ,
562: the input file already met the sorting criteria.
1.39 jmc 563: .It 1
1.41 millert 564: On disorder (or non-uniqueness) with the
1.39 jmc 565: .Fl C
566: or
567: .Fl c
1.41 millert 568: options.
1.39 jmc 569: .It 2
570: An error occurred.
1.1 millert 571: .El
572: .Sh SEE ALSO
573: .Xr comm 1 ,
1.3 aaron 574: .Xr join 1 ,
1.47 jmc 575: .Xr uniq 1
1.27 dlg 576: .Sh STANDARDS
577: The
578: .Nm
1.28 jmc 579: utility is compliant with the
1.33 jmc 580: .St -p1003.1-2008
1.27 dlg 581: specification.
582: .Pp
583: The flags
1.43 jmc 584: .Op Fl gHhiMRSsTVz
1.28 jmc 585: are extensions to that specification.
1.41 millert 586: .Pp
587: All long options are extensions to the specification.
588: Some are provided for compatibility with GNU
589: .Nm ,
590: others are specific to this implementation.
1.54 millert 591: .Pp
592: Some implementations of
593: .Nm
594: honor the
595: .Fl b
596: option even when no key fields are specified.
597: This implementation follows historic practice and
598: .St -p1003.1-2008
599: in only honoring
600: .Fl b
601: when it precedes a key field.
1.52 millert 602: .Pp
603: The historic practice of allowing the
604: .Fl o
605: option to appear after the
606: .Ar file
607: is supported for compatibility with older versions of
608: .Nm .
1.41 millert 609: .Pp
610: The historic key notations
611: .Cm \(pl Ns Ar pos1
612: and
613: .Fl Ns Ar pos2
614: are supported for compatibility with older versions of
615: .Nm
616: but their use is highly discouraged.
1.1 millert 617: .Sh HISTORY
618: A
1.8 aaron 619: .Nm
1.1 millert 620: command appeared in
1.16 mickey 621: .At v3 .
1.41 millert 622: .Sh AUTHORS
1.44 jmc 623: .An Gabor Kovesdan Aq Mt gabor@FreeBSD.org
624: .An Oleg Moskalenko Aq Mt mom040267@gmail.com
1.45 jmc 625: .Sh CAVEATS
1.41 millert 626: This implementation of
1.14 ericj 627: .Nm
628: has no limits on input line length (other than imposed by available
629: memory) or any restrictions on bytes allowed within lines.
630: .Pp
1.41 millert 631: The performance depends highly on locale settings,
632: efficient choice of sort keys and key complexity.
633: The fastest sort is with the C locale, on whole lines, with option
634: .Fl s .
635: In general, the C locale is the fastest, followed by single-byte
636: locales with multi-byte locales being the slowest.
637: The correct collation order respected in all cases.
638: For the key specification, the simpler to process the
639: lines the faster the search will be.
1.14 ericj 640: .Pp
1.41 millert 641: When sorting by arithmetic value, using
642: .Fl n
643: results in much better performance than
644: .Fl g
645: so its use is encouraged whenever possible.