diff options
Diffstat (limited to 'doc/lsort.n')
-rw-r--r-- | doc/lsort.n | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/doc/lsort.n b/doc/lsort.n index 6253a5e..f83ace5 100644 --- a/doc/lsort.n +++ b/doc/lsort.n @@ -7,7 +7,7 @@ '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" -'\" RCS: @(#) $Id: lsort.n,v 1.31 2008/09/29 13:33:18 dkf Exp $ +'\" RCS: @(#) $Id: lsort.n,v 1.32 2008/10/17 10:22:25 dkf Exp $ '\" .so man.macros .TH lsort n 8.5 Tcl "Tcl Built-In Commands" @@ -88,11 +88,14 @@ element and the \fIindexList\fR were passed to \fBlindex\fR) and sort based on the given element. For example, .RS +.PP .CS lsort -integer -index 1 \e {{First 24} {Second 18} {Third 30}} .CE -returns \fB{Second 18} {First 24} {Third 30}\fR, and +.PP +returns \fB{Second 18} {First 24} {Third 30}\fR, +.PP '\" '\" This example is from the test suite! '\" @@ -100,8 +103,10 @@ returns \fB{Second 18} {First 24} {Third 30}\fR, and lsort -index end-1 \e {{a 1 e i} {b 2 3 f g} {c 4 5 6 d h}} .CE +.PP returns \fB{c 4 5 6 d h} {a 1 e i} {b 2 3 f g}\fR, and +.PP .CS lsort -index {0 1} { {{b i g} 12345} @@ -109,6 +114,7 @@ lsort -index {0 1} { {{c o d e} 54321} } .CE +.PP returns \fB{{d e m o} 34512} {{b i g} 12345} {{c o d e} 54321}\fR (because \fBe\fR sorts before \fBi\fR which sorts before \fBo\fR.) This option is much more efficient than using \fB\-command\fR @@ -129,15 +135,19 @@ The list length must be an integer multiple of \fIstrideLength\fR, which in turn must be at least 2. .PP For example, +.PP .CS lsort \-stride 2 {carrot 10 apple 50 banana 25} .CE +.PP returns .QW "apple 50 banana 25 carrot 10" , and +.PP .CS lsort \-stride 2 \-index 1 \-integer {carrot 10 apple 50 banana 25} .CE +.PP returns .QW "carrot 10 banana 25 apple 50" . .RE @@ -169,18 +179,21 @@ option. .SH "EXAMPLES" .PP Sorting a list using ASCII sorting: +.PP .CS % \fBlsort\fR {a10 B2 b1 a1 a2} B2 a1 a10 a2 b1 .CE .PP Sorting a list using Dictionary sorting: +.PP .CS % \fBlsort\fR -dictionary {a10 B2 b1 a1 a2} a1 a2 a10 b1 B2 .CE .PP Sorting lists of integers: +.PP .CS % \fBlsort\fR -integer {5 3 1 2 11 4} 1 2 3 4 5 11 @@ -189,6 +202,7 @@ Sorting lists of integers: .CE .PP Sorting lists of floating-point numbers: +.PP .CS % \fBlsort\fR -real {5 3 1 2 11 4} 1 2 3 4 5 11 @@ -197,6 +211,7 @@ Sorting lists of floating-point numbers: .CE .PP Sorting using indices: +.PP .CS % # Note the space character before the c % \fBlsort\fR {{a 5} { c 3} {b 4} {e 1} {d 2}} @@ -209,6 +224,7 @@ Sorting using indices: .PP .VS 8.6 Sorting a dictionary: +.PP .CS % set d [dict create c d a b h i f g c e] c e a b h i f g @@ -217,6 +233,7 @@ a b c e f g h i .CE .PP Sorting using striding and multiple indices: +.PP .CS % # Note the first index value is relative to the group % \fBlsort\fR \-stride 3 \-index {0 1} \e @@ -226,12 +243,14 @@ Sorting using striding and multiple indices: .VE 8.6 .PP Stripping duplicate values using sorting: +.PP .CS % \fBlsort\fR -unique {a b c a b c a b c} a b c .CE .PP More complex sorting using a comparison function: +.PP .CS % proc compare {a b} { set a0 [lindex $a 0] |