Like all tkWorld applications, tkSort is pretty smart. Without filling in any entries, click on the Run button.
Notice the Beattle's Yellow Submarine
takes a voyage, the Filename is filled in, and the Log Window has the following text in it
Goldstein, Jerry|523 S. School St. #605|Hanover|NH|43939 Grabbe, Shon|6540 Dumpling Dr.|Sacramento|CA|32456 King, David|311 Wakegan Ave.|Chicago|IL|45323 Troike, Marc|1003 Leviathon Ln.|Dayton|OH|45034 Wright, Timothy|2342 Woodlands Way|Houston|TX|77056The example file is a simple address book database file. It has several fields listed below in order of appearance
The funny character between each field is called a pipe. This is the standard format of a Unix database file. The separator is usually a character which will not appear in the text fields. The pipe character has been chosen for the example because it visually indicates each field.
If you want to sort the file in reverse order, just turn on the -r option. Using this option on the example file gives
Wright, Timothy|2342 Woodlands Way|Houston|TX|77056 Troike, Marc|1003 Leviathon Ln.|Dayton|OH|45034 King, David|311 Wakegan Ave.|Chicago|IL|45323 Grabbe, Shon|6540 Dumpling Dr.|Sacramento|CA|32456 Goldstein, Jerry|523 S. School St. #605|Hanover|NH|43939Notice now that Mr. Goldstein is at the bottom of the list where he belongs!
Suppose your address book entry system did not alert you that you have put in a duplicate address. Now instead of just one entry for your friend Marc Troike, there are two entries
King, David|311 Wakegan Ave.|Chicago|IL|45323 Grabbe, Shon|6540 Dumpling Dr.|Sacramento|CA|32456 Goldstein, Jerry|523 S. School St. #605|Hanover|NH|43939 Troike, Marc|1003 Leviathon Ln.|Dayton|OH|45034 Troike, Marc|1003 Leviathon Ln.|Dayton|OH|45034 Wright, Timothy|2342 Woodlands Way|Houston|TX|77056If you turn on the -u option, only unique lines appear in the output
Goldstein, Jerry|523 S. School St. #605|Hanover|NH|43939 Grabbe, Shon|6540 Dumpling Dr.|Sacramento|CA|32456 King, David|311 Wakegan Ave.|Chicago|IL|45323 Troike, Marc|1003 Leviathon Ln.|Dayton|OH|45034 Wright, Timothy|2342 Woodlands Way|Houston|TX|77056Notice there is only 1 entry for Mr. Troike now!
A few months after using tkSort, you have made a new friend and need to enter her address into your file. Afraid of Carpal Tunnel Syndrome from all the typing, you put her address in lowercase
King, David|311 Wakegan Ave.|Chicago|IL|45323 Grabbe, Shon|6540 Dumpling Dr.|Sacramento|CA|32456 Goldstein, Jerry|523 S. School St. #605|Hanover|NH|43939 Troike, Marc|1003 Leviathon Ln.|Dayton|OH|45034 Wright, Timothy|2342 Woodlands Way|Houston|TX|77056 martuccio, michelle|2389 colby ave.|east rutherford|nj|34543Another few months pass and you decide you want an alphabetical listing of you address book. Running plain sort on the above file gives
Goldstein, Jerry|523 S. School St. #605|Hanover|NH|43939 Grabbe, Shon|6540 Dumpling Dr.|Sacramento|CA|32456 King, David|311 Wakegan Ave.|Chicago|IL|45323 Troike, Marc|1003 Leviathon Ln.|Dayton|OH|45034 Wright, Timothy|2342 Woodlands Way|Houston|TX|77056 martuccio, michelle|2389 colby ave.|east rutherford|nj|34543Hey! Wait a minute! Why is martuccio last? The reason is that uppercase letters come before lowercase letters, this is just how the ASCII character set works. To avoid this problem, you must fold the lines using the -f option.
Goldstein, Jerry|523 S. School St. #605|Hanover|NH|43939 Grabbe, Shon|6540 Dumpling Dr.|Sacramento|CA|32456 King, David|311 Wakegan Ave.|Chicago|IL|45323 martuccio, michelle|2389 colby ave.|east rutherford|nj|34543 Troike, Marc|1003 Leviathon Ln.|Dayton|OH|45034 Wright, Timothy|2342 Woodlands Way|Houston|TX|77056
This option ignores character case by folding all the lowercase letters into uppercase characters before any comparisons between lines are made. Now Michelle is in the correct place in the list.