{"id":11305,"date":"2014-12-30T05:04:08","date_gmt":"2014-12-29T18:04:08","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=11305"},"modified":"2014-12-30T05:04:08","modified_gmt":"2014-12-29T18:04:08","slug":"linux-sort-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/linux-sort-tutorial\/","title":{"rendered":"Linux sort Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Linux\/sort\/\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"Linux sort Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/Linux\/sort\/Linux_sort-45of.jpg\" title=\"Linux sort Primer Tutorial\" id='ilst' onmouseover='  this.src=this.src.replace(\"45\",\"z6\").replace(\"46\",\"z7\").replace(\"47\",\"z8\").replace(\"48\",\"z9\").replace(\"49\",\"Z0\").replace(\"50\",\"Z1\").replace(\"51\",\"Z2\").replace(\"52\",\"Z3\").replace(\"53\",\"z5\").replace(\"z\",\"4\").replace(\"Z\",\"5\");              ' \/><\/a><p class=\"wp-caption-text\">Linux sort Tutorial<\/p><\/div>\n<p>If you were to nominate the most frequent &#8220;chore&#8221; you set your &#8220;software programs&#8221; to do, and we should never forget we are here to make software that achieves something, there is a big chance you&#8217;d choose the job of <i>sort<\/i>ing data.  The <i>why<\/i> I guess relates to how a lot of we humans want data presented &#8230; we seek order &#8230; and are generally a bit afraid of chaos &#8230; whether this is good always is for 56784532 other conversations to have.<\/p>\n<p>Let&#8217;s go back to a thinking close to the operating system of interest &#8230; and today that is Linux &#8230; and look at some command line Linux that will work on most\/all Linux or Unix operating systems &#8230; it is pretty fundamental stuff.<\/p>\n<p>The base command of interest may amaze you &#8230; are you ready &#8230;<\/p>\n<p><code><br \/>\n<a target=_blank title='Linux sort information' href='http:\/\/unixhelp.ed.ac.uk\/CGI\/man-cgi?sort'>sort<\/a> [inputFile]<br \/>\n<\/code><\/p>\n<p>&#8230; gasp &#8230; but <i>sort<\/i> just like that assumes some of the defaults (depending on your deep configuration settings (ie. in your profile, with an <a target=_blank title='Linux alias information' href='http:\/\/www.brighthub.com\/computing\/linux\/articles\/79232.aspx'>alias<\/a>, you can change them)) &#8230;<\/p>\n<ul>\n<li>alphabetical sorting<\/li>\n<li>total record sorting (as if all the characters on a carriage return\/line feed <a target=_blank title='Delimiter information from Wikipedia ... thanks' href='http:\/\/en.wikipedia.org\/wiki\/Delimiter'>delimited<\/a> string)<\/li>\n<li>ascending sort (from least to greatest)<\/li>\n<li>the sort determination looks from the leftmost character and proceeds to the right<\/li>\n<\/ul>\n<p>&#8230; but, today, with our <a target=_blank title='Piping information from Wikipedia ... thanks' href='http:\/\/en.wikipedia.org\/wiki\/Pipeline_%28Unix%29'>piped<\/a> <i>sort<\/i> commands we present <a target=_blank title='Great site for Unix\/Linux switch information' href='http:\/\/www.computerhope.com\/unix\/usort.htm'>switches<\/a> that can change the first three defaults, respectively &#8230;<\/p>\n<ul>\n<li>-n<\/li>\n<li>-k [colNumber] -t[delimiterCharacter]<\/li>\n<li>-r<\/li>\n<\/ul>\n<p>&#8230; in other words &#8230;<\/p>\n<ul>\n<li>numerical sort<\/li>\n<li>sort by field [colNumber] where fields are separated by [delimiterCharacter]<\/li>\n<li>descending sort<\/li>\n<\/ul>\n<p>We also touch on other commands with our look at Linux sorting of our input <a target=_blank title='Comma separated value information from Wikipedia ... thanks' href='http:\/\/en.wikipedia.org\/wiki\/Comma-separated_values'>CSV<\/a> data that we talked about with <a target=_blank href='#pjhgcjdtioct' title='PHP\/Javascript\/HTML Google Chart JSON Data Table Import of CSV Tutorial'>PHP\/Javascript\/HTML Google Chart JSON Data Table Import of CSV Tutorial<\/a> as shown below that has fields &#8220;Country&#8221;,&#8221;Population&#8221;,&#8221;Crude Birth Rate&#8221; &#8230;<\/p>\n<ul>\n<li><a target=_blank title='Linux cat information' href='http:\/\/unixhelp.ed.ac.uk\/CGI\/man-cgi?cat'>cat<\/a> [CSVfileName] &#8230; type a file called [CSVfileName]<\/li>\n<li><a target=_blank title='Linux uniq information' href='http:\/\/unixhelp.ed.ac.uk\/CGI\/man-cgi?uniq'>uniq<\/a> &#8230; pipe to enforce record uniqueness<\/li>\n<li>sort -u &#8230; pipe and switch to enforce field (of record) uniqueness<\/li>\n<li><a target=_blank title='Linux grep information' href='http:\/\/unixhelp.ed.ac.uk\/CGI\/man-cgi?grep'>grep<\/a> &#8216;[searchCriteria]&#8217; &#8230; piped filter to include only records satisfying [searchCriteria]<\/li>\n<li><a target=_blank title='Linux sed information' href='http:\/\/unixhelp.ed.ac.uk\/CGI\/man-cgi?sed'>sed<\/a> &#8216;\/$\/s\/\/,5\/g&#8217; &#8230; piped record modifier adding a new column (ie. ,5) to right of our input CSV data<\/li>\n<\/ul>\n<p>Hope you find some interest in this Linux operating system command <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Linux\/sort\/\" title=\"Click picture\">discussion<\/a>.  This is raw command line talk but it can also be supervised as a useful component tool by, (amongst other ideas by) &#8230;<\/p>\n<ul>\n<li>web server side language supervision &#8230; eg. via PHP <a target=_blank title='PHP exec method information' href='http:\/\/php.net\/manual\/en\/function.exec.php'><i>exec<\/i><\/a> for example, or via <a target=_blank title='cURL information from Wikipedia ... thanks' href='http:\/\/en.wikipedia.org\/wiki\/CURL'><i>curl<\/i><\/a> (of that PHP)<\/li>\n<li>called by compiled desktop program, such as <a target=_blank title='Java exec process ... Runtime class ... information' href='http:\/\/alvinalexander.com\/java\/edu\/pj\/pj010016'>Java<\/a>, <a target=_blank title='C++ system command' href='http:\/\/www.cplusplus.com\/reference\/cstdlib\/system\/'>C++<\/a>, <a target=_blank title='C system command' href='http:\/\/www.tutorialspoint.com\/c_standard_library\/c_function_system.htm'>C<\/a><\/li>\n<li>called by a Linux\/Unix <a target=_blank title='Linux shell script information' href='http:\/\/www.freeos.com\/guides\/lsst\/'>shell script<\/a> &#8230; in Bourne Shell, Korn Shell, C Shell, tcsh, Unix Shell<\/li>\n<\/ul>\n<hr \/>\n<p id='pjhgcjdtioct'>Previous relevant data from <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=3770' title='PHP\/Javascript\/HTML Google Chart JSON Data Table Import of CSV Tutorial'>PHP\/Javascript\/HTML Google Chart JSON Data Table Import of CSV Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/ChartEditor\/json_data_table.php?infile=Google_Chart_Intensity_Chart_Tutorial_as.CSV\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"PHP\/Javascript\/HTML Google Chart JSON Data Table Import of CSV Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/ChartEditor\/Json_Data_Table.jpg\" title=\"PHP\/Javascript\/HTML Google Chart JSON Data Table Import of CSV Tutorial\" \/><\/a><p class=\"wp-caption-text\">PHP\/Javascript\/HTML Google Chart JSON Data Table Import of CSV Tutorial<\/p><\/div>\n<p>Here is a tutorial that introduces you to Google Graphs API, or Google Chart Tools, and its JSON Data Table functionality.<\/p>\n<blockquote><p>Google Chart Tools provide a perfect way to visualize data on your website. From simple line charts to complex hierarchical tree maps, the chart galley provides a large number of well-designed chart types. Populating your data is easy using the provided client- and server-side tools.<\/p><\/blockquote>\n<p>Thanks to the World Bank for some <a target=_blank title='World Bank data' href='http:\/\/wdi.worldbank.org\/table\/2.1'>statistics<\/a> which helped a lot.<\/p>\n<p>Let&#8217;s see some  <a target=_blank title='click picture' href='http:\/\/www.rjmprogramming.com.au\/PHP\/ChartEditor\/json_data_table.php?infile=Google_Chart_Intensity_Chart_Tutorial_as.CSV'>PHP<\/a> code in live action for this tutorial where you see a JSON Data Table derived from a filename passed as a parameter in the URL.   The data shown is based on a CSV file of a previous <a <a href=\"#pjhgcimt\">PHP\/Javascript\/HTML Google Chart Intensity Map Tutorial<\/a> shown below.<\/p>\n<p>Link to Google Chart Tools &#8220;spiritual home&#8221; &#8230; <a target=_blank href='https:\/\/developers.google.com\/chart\/interactive\/docs\/index' title='Google Chart Tools provide a perfect way to visualize data on your website. From simple line charts to complex hierarchical tree maps, the chart galley provides a large number of well-designed chart types. Populating your data is easy using the provided client- and server-side tools.\n'>via Google<\/a>.<br \/>\nLink to Google Chart Tools JSON Data Table information &#8230; <a target=_blank href='http:\/\/code.google.com\/apis\/ajax\/playground\/?type=visualization#json_data_table' title='Google Json Data Table'>via Google<\/a>.<\/p>\n<p>Link to some downloadable PHP programming code &#8230; rename to <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/PHP\/ChartEditor\/chart_editor_in.php_GETME' title='Download me'>chart_editor_in.php<\/a>.<br \/>\nLink to some downloadable PHP programming code &#8230; rename to <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/PHP\/ChartEditor\/json_data_table.php_GETME' title='Download me'>json_data_table.php<\/a>.<br \/>\nLink to some downloadable input CSV data &#8230; rename to <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/PHP\/ChartEditor\/intensity_chart.csv_GETME' title='Download me'>Google_Chart_Intensity_Chart_Tutorial_as.CSV<\/a>.\n<\/p>\n<hr \/>\n<p id='pjhgcimt'>Previous  <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/IntensityChart\/intensity_chart.php\" title=\"PHP\/Javascript\/HTML Google Chart Intensity Map Tutorial\">PHP\/Javascript\/HTML Google Chart Intensity Map Tutorial<\/a> below &#8230;<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/IntensityChart\/intensity_chart.php\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"PHP\/Javascript\/HTML Google Chart Intensity Map Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/IntensityChart\/Intensity_Map.jpg\" title=\"PHP\/Javascript\/HTML Google Chart Intensity Map Tutorial\" \/><\/a><p class=\"wp-caption-text\">PHP\/Javascript\/HTML Google Chart Intensity Map Tutorial<\/p><\/div>\n<p>Here is a tutorial that introduces you to Google Graphs API, or Google Chart Tools, and its Intensity Map functionality.<\/p>\n<blockquote><p>Google Chart Tools provide a perfect way to visualize data on your website. From simple line charts to complex hierarchical tree maps, the chart galley provides a large number of well-designed chart types. Populating your data is easy using the provided client- and server-side tools.<\/p><\/blockquote>\n<p>Thanks to the World Bank for some <a target=_blank title='World Bank data' href='http:\/\/wdi.worldbank.org\/table\/2.1'>statistics<\/a> which helped a lot.<\/p>\n<p>Let&#8217;s see some  <a target=_blank title='click picture' href='http:\/\/www.rjmprogramming.com.au\/PHP\/IntensityChart\/intensity_chart.php'>PHP<\/a> code in live action for this tutorial where you define your intensity map characteristics and data.<\/p>\n<p>Now part of an Android App called <a target=_blank title='Android App GeoChart++' href='https:\/\/play.google.com\/store\/apps\/details?id=com.rjmprogramming.geochart.plusplus#?t=W251bGwsMSwyLDIxMiwiY29tLnJqbXByb2dyYW1taW5nLmdlb2NoYXJ0LnBsdXNwbHVzIl0.'>Geo Chart++<\/a> in July 2013.<\/p>\n<p>Link to Google Chart Tools &#8220;spiritual home&#8221; &#8230; <a target=_blank href='https:\/\/developers.google.com\/chart\/interactive\/docs\/index' title='Google Chart Tools provide a perfect way to visualize data on your website. From simple line charts to complex hierarchical tree maps, the chart galley provides a large number of well-designed chart types. Populating your data is easy using the provided client- and server-side tools.\n'>via Google<\/a>.<br \/>\nLink to Google Chart Tools Intensity Map information &#8230; <a target=_blank href='http:\/\/code.google.com\/apis\/ajax\/playground\/?type=visualization#intensity_map' title='Google Geo Charts'>via Google<\/a>.<\/p>\n<p>Link to some downloadable PHP programming code &#8230; rename to <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/PHP\/IntensityChart\/intensity_chart.php_GETME' title='Download me'>intensity_chart.php<\/a>.\n<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d2995' onclick='var dv=document.getElementById(\"d2995\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?s=Google+Chart#content\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d2995' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr \/>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d3770' onclick='var dv=document.getElementById(\"d3770\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?s=Google+Chart#content\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d3770' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr \/>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d11305' onclick='var dv=document.getElementById(\"d11305\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=Linux\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d11305' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>If you were to nominate the most frequent &#8220;chore&#8221; you set your &#8220;software programs&#8221; to do, and we should never forget we are here to make software that achieves something, there is a big chance you&#8217;d choose the job of &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/linux-sort-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,29,37],"tags":[71,191,233,234,283,544,707,885,946,997,1173,1231,1319,1335,1339],"class_list":["post-11305","post","type-post","status-publish","format-standard","hentry","category-elearning","category-operating-system","category-tutorials","tag-alias","tag-cat","tag-command","tag-command-line","tag-csv","tag-grep","tag-linux","tag-operating-system-2","tag-pipe","tag-programming","tag-sort","tag-switches","tag-tutorial","tag-uniq","tag-unix"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/11305"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=11305"}],"version-history":[{"count":0,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/11305\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=11305"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=11305"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=11305"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}