{"id":11198,"date":"2015-06-29T22:12:14","date_gmt":"2015-06-29T22:12:14","guid":{"rendered":"http:\/\/www.oracletutoring.ca\/blog\/?p=11198"},"modified":"2015-06-29T22:12:14","modified_gmt":"2015-06-29T22:12:14","slug":"windows-terminal-the-sort-function","status":"publish","type":"post","link":"https:\/\/www.oracletutoring.ca\/blog\/windows-terminal-the-sort-function\/","title":{"rendered":"Windows terminal:  the sort function"},"content":{"rendered":"<h1>The tutor shares a great find on the Windows terminal.<\/h1>\n<p>When I was a kid, we spent many hours, in grades three through six, rewriting lists of words in alphabetical order.  The advantage was twofold:  writing practice (which, back then, was practically half of elementary school) and understanding how words are ordered in a dictionary.  Those exercises could be ponderous; here I am, anyway:)<\/p>\n<p>Today, you needn&#8217;t alphabetize a list yourself.  Just type it, one word per line, to a file, then let the Windows terminal <span style=\"font-family:monospace\">sort<\/span> function take care of it.  The basic syntax, at the command prompt, is<br \/>\n<span style=\"font-family:monospace;color:maroon\"><br \/>\nsort <i>input_file<\/i> \/o <i>output_file<\/i><\/span><\/p>\n<p>To test the <span style=\"font-family:monospace\">sort<\/span> command, I first created a file called <span style=\"font-family:monospace\">tosort0.txt<\/span>.  Its contents:<br \/>\n<span style=\"font-family:monospace\"><br \/>\nlewis<br \/>\nlouise<br \/>\ntender<br \/>\nant<br \/>\nimportation<br \/>\n22<br \/>\n101<br \/>\n01<br \/>\na<br \/>\n!<br \/>\n<\/span><\/p>\n<p>At the command prompt, I then ran<br \/>\n<span style=\"font-family:monospace;color:maroon\"><br \/>\nsort tosort0.txt \/o sorted0.txt<\/p>\n<p>Next, I opened the file <span style=\"font-family:monospace\">sorted0.txt<\/span>, which hadn&#8217;t existed before.  Indeed, its contents are<br \/>\n<span style=\"font-family:monospace\"><br \/>\n!<br \/>\n01<br \/>\n101<br \/>\n22<br \/>\na<br \/>\nant<br \/>\nimportation<br \/>\nlewis<br \/>\nlouise<br \/>\ntender<br \/>\n<\/span><\/p>\n<p>However, the file <span style=\"font-family:monospace\">tosort0.txt<\/span> remains unchanged.<\/p>\n<p>Next I ran, from the command line,<br \/>\n<span style=\"font-family:monospace;color:maroon\"><br \/>\nsort tosort0.txt<br \/>\n<\/span><\/p>\n<p>The list, in alphabetical order, printed to the screen.<\/p>\n<p>Once again:  if you don&#8217;t specify the output file, you&#8217;ll see the sorted list print right to the command line.  If you specify an output file that doesn&#8217;t exist, the command will create it, then print the sorted list to it.  The input file whose contents get sorted remains unchanged.<\/p>\n<p>Neat, huh?<\/p>\n<p>Jack of <a href=\"https:\/\/www.oracletutoring.ca\">Oracle Tutoring by Jack and Diane,<\/a> Campbell River, BC.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The tutor shares a great find on the Windows terminal. When I was a kid, we spent many hours, in grades three through six, rewriting lists of words in alphabetical order. The advantage was twofold: writing practice (which, back then, &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/www.oracletutoring.ca\/blog\/windows-terminal-the-sort-function\/\"> <span class=\"screen-reader-text\">Windows terminal:  the sort function<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[105,904],"tags":[908,907,905,906],"class_list":["post-11198","post","type-post","status-publish","format-standard","hentry","category-computer-science","category-windows","tag-command-line","tag-command-prompt","tag-sort-command","tag-windows-terminal"],"_links":{"self":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/11198","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/comments?post=11198"}],"version-history":[{"count":17,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/11198\/revisions"}],"predecessor-version":[{"id":11215,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/11198\/revisions\/11215"}],"wp:attachment":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/media?parent=11198"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/categories?post=11198"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/tags?post=11198"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}