Windows Command Line Interactive sort Tutorial

Windows Command Line Interactive sort Primer Tutorial

Windows Command Line Interactive sort Tutorial

Today’s blog posting was going to be called Windows Command Line Piped sort Tutorial, but, alas, there is a good reason the Windows (MS-DOS) sort command is an exe file … you need a compiled program to work the piping, though am not willing to concede that it cannot be done with just DOS Batch programming … think a file just containing ctrl-Z would be interesting … but it is not straightforward, that is for sure.

Anyway, that is by the by and today we show a bit of use of the “copy con” MS-DOS command usage and along the way discovered newer DOS (an oxymoron maybe?) versions contain the equivalent of the wonderful Linux tee command, and this could be of good use.

So we are adding to yesterday’s Windows Command Line sort Tutorial as shown below.

If you were to nominate the most frequent “chore” you set your “software programs” to do, and we should never forget we are here to make software that achieves something, there is a big chance you’d choose the job of sorting data. The why I guess relates to how a lot of we humans want data presented … we seek order … and are generally a bit afraid of chaos … whether this is good always is for 56784534 other conversations to have.

Let’s go back to a thinking close to the operating system of interest … and today that is Windows (remember when we covered Linux sort Tutorial as shown bit further below?) … specifically its command line, and only its command line … in the old days called DOS or (MS-DOS) … we set ourselves the task not to compile anything … just straight DOS batch … and look at some command line Windows Command Line that will work on most/all Windows operating systems … it is pretty fundamental stuff, and we use the same CSV input data file as for the tutorial below (though, as of this tutorial, if you specify a non-existant file it will create this as output, and it will now accept no input file) so that you can compare and contrast.

The base command of interest may amaze you … are you ready …


sort [inputFile]

… gasp … but sort just like that (without switches) assumes …

  1. alphabetical sorting (okay as switch in Linux sort but not in DOS sort, as a switch)
  2. total record sorting (in DOS sort can have a character position to start at as a switch, but this seldom suits CSV sorting) (as if all the characters on a carriage return/line feed delimited string)
  3. ascending sort (from least to greatest) (in DOS there is a “/r” switch (for reverse sort) available)
  4. the sort determination looks from the leftmost character and proceeds to the right

… but, today, with our piped sort commands (unfortunately not additionally accompanied by a corresponding piped csvsort[.bat] scenario … boo hoo) we present switches that can work with the first three defaults, respectively, the first two of which we have to tailor some DOS Batch programming code …

  • /n (we invent for our job)
  • we will assume a comma as a delimiter and allow user to specify a (single) field number to sort on
  • /r (as said above, exists in DOS sort command now, and we will allow its usage … doh!)

… in other words …

  • numerical sort
  • sort by field [colNumber] where fields are separated by comma
  • descending sort

So doing this proved pretty ugly when you don’t involve any compiled code … and we came up with …

Link to the supervising csvsort.bat with the usage instructions …

@rem csvsort.bat
@rem RJM Programming – January, 2015
@rem Defaults to three comma separated fields to sort and default csv3.bat and vsc3.bat as written
@rem Usage: csvsort[.bat] [[numFields] [rowsToSkip]] [inputCSVFilename] [fieldNumberOfSort] [/n] [/r]
@rem Note: If no inputSVFilename existing it will ask for interactive input
@rem Defaults: /n does numerical sort and /r reverses the sort
@rem Defaults: rowsToSkip=0 fieldNumberOfSort=1 (starting at 1) numFields=3 (if specified please also specify a rowsToSkip value)

Link to the supervised (and only suitable for 3 column record CSV files … if feeling strong, write others for your own purpose) … csv3.bat and vsc3.bat and the more generic lpad10.bat

Links to the how we got there … supervising … csvsort.bat … to the supervised (and only suitable for 3 column record CSV files … if feeling strong, write others for your own purpose) … csv3.bat and vsc3.bat and the more generic lpad10.bat


Previous relevant Windows Command Line sort Tutorial is shown below.

Windows Command Line sort Primer Tutorial

Windows Command Line sort Tutorial

If you were to nominate the most frequent “chore” you set your “software programs” to do, and we should never forget we are here to make software that achieves something, there is a big chance you’d choose the job of sorting data. The why I guess relates to how a lot of we humans want data presented … we seek order … and are generally a bit afraid of chaos … whether this is good always is for 56784533 other conversations to have.

Let’s go back to a thinking close to the operating system of interest … and today that is Windows (remember when we covered Linux sort Tutorial as shown below?) … specifically its command line, and only its command line … in the old days called DOS or (MS-DOS) … we set ourselves the task not to compile anything … just straight DOS batch … and look at some command line Windows Command Line that will work on most/all Windows operating systems … it is pretty fundamental stuff, and we use the same CSV input data file as for the tutorial below so that you can compare and contrast.

The base command of interest may amaze you … are you ready …


sort [inputFile]

… gasp … but sort just like that (without switches) assumes …

  1. alphabetical sorting (okay as switch in Linux sort but not in DOS sort, as a switch)
  2. total record sorting (in DOS sort can have a character position to start at as a switch, but this seldom suits CSV sorting) (as if all the characters on a carriage return/line feed delimited string)
  3. ascending sort (from least to greatest) (in DOS there is a “/r” switch (for reverse sort) available)
  4. the sort determination looks from the leftmost character and proceeds to the right

… but, today, with our piped sort commands we present switches that can work with the first three defaults, respectively, the first two of which we have to tailor some DOS Batch programming code …

  • /n (we invent for our job)
  • we will assume a comma as a delimiter and allow user to specify a (single) field number to sort on
  • /r (as said above, exists in DOS sort command now, and we will allow its usage … doh!)

… in other words …

  • numerical sort
  • sort by field [colNumber] where fields are separated by comma
  • descending sort

So doing this proved pretty ugly when you don’t involve any compiled code … and we came up with …

Link to the supervising csvsort.bat with the usage instructions …

@rem csvsort.bat
@rem RJM Programming – January, 2015
@rem Defaults to three comma separated fields to sort and default csv3.bat and vsc3.bat as written
@rem Usage: csvsort[.bat] [[numFields] [rowsToSkip]] [inputCSVFilename] [fieldNumberOfSort] [/n] [/r]
@rem Note: If no inputSVFilename existing it will ask for interactive input
@rem Defaults: /n does numerical sort and /r reverses the sort
@rem Defaults: rowsToSkip=0 fieldNumberOfSort=1 (starting at 1) numFields=3 (if specified please also specify a rowsToSkip value)

Link to the supervised (and only suitable for 3 column record CSV files … if feeling strong, write others for your own purpose) … csv3.bat and vsc3.bat and the more generic lpad10.bat


sort [inputFile]

… gasp … but sort just like that (without switches) assumes …

  1. alphabetical sorting (okay as switch in Linux sort but not in DOS sort, as a switch)
  2. total record sorting (in DOS sort can have a character position to start at as a switch, but this seldom suits CSV sorting) (as if all the characters on a carriage return/line feed delimited string)
  3. ascending sort (from least to greatest) (in DOS there is a “/r” switch (for reverse sort) available)
  4. the sort determination looks from the leftmost character and proceeds to the right

… but, today, with our piped sort commands we present switches that can work with the first three defaults, respectively, the first two of which we have to tailor some DOS Batch programming code …

  • /n (we invent for our job)
  • we will assume a comma as a delimiter and allow user to specify a (single) field number to sort on
  • /r (as said above, exists in DOS sort command now, and we will allow its usage … doh!)

… in other words …

  • numerical sort
  • sort by field [colNumber] where fields are separated by comma
  • descending sort

So doing this proved pretty ugly when you don’t involve any compiled code … and we came up with …

Link to the supervising csvsort.bat with the usage instructions …

@rem csvsort.bat
@rem RJM Programming – January, 2015
@rem Defaults to three comma separated fields to sort and default csv3.bat and vsc3.bat as written
@rem Usage: csvsort[.bat] [[numFields] [rowsToSkip]] inputCSVFilename [fieldNumberOfSort] [/n] [/r]
@rem Defaults: /n does numerical sort and /r reverses the sort
@rem Defaults: rowsToSkip=0 fieldNumberOfSort=1 (starting at 1) numFields=3 (if specified please also specify a rowsToSkip value)

Link to the supervised (and only suitable for 3 column record CSV files … if feeling strong, write others for your own purpose) … csv3.bat and vsc3.bat and the more generic lpad10.bat


Previous relevant and contrasting Linux sort Tutorial is shown below.

Linux sort Primer Tutorial

Linux sort Tutorial

If you were to nominate the most frequent “chore” you set your “software programs” to do, and we should never forget we are here to make software that achieves something, there is a big chance you’d choose the job of sorting data. The why I guess relates to how a lot of we humans want data presented … we seek order … and are generally a bit afraid of chaos … whether this is good always is for 56784532 other conversations to have.

Let’s go back to a thinking close to the operating system of interest … and today that is Linux … and look at some command line Linux that will work on most/all Linux or Unix operating systems … it is pretty fundamental stuff.

The base command of interest may amaze you … are you ready …


sort [inputFile]

… gasp … but sort just like that assumes some of the defaults (depending on your deep configuration settings (ie. in your profile, with an alias, you can change them)) …

  • alphabetical sorting
  • total record sorting (as if all the characters on a carriage return/line feed delimited string)
  • ascending sort (from least to greatest)
  • the sort determination looks from the leftmost character and proceeds to the right

… but, today, with our piped sort commands we present switches that can change the first three defaults, respectively …

  • -n
  • -k [colNumber] -t[delimiterCharacter]
  • -r

… in other words …

  • numerical sort
  • sort by field [colNumber] where fields are separated by [delimiterCharacter]
  • descending sort

We also touch on other commands with our look at Linux sorting of our input CSV data that we talked about with PHP/Javascript/HTML Google Chart JSON Data Table Import of CSV Tutorial as shown below that has fields “Country”,”Population”,”Crude Birth Rate” …

  • cat [CSVfileName] … type a file called [CSVfileName]
  • uniq … pipe to enforce record uniqueness
  • sort -u … pipe and switch to enforce field (of record) uniqueness
  • grep ‘[searchCriteria]’ … piped filter to include only records satisfying [searchCriteria]
  • sed ‘/$/s//,5/g’ … piped record modifier adding a new column (ie. ,5) to right of our input CSV data

Hope you find some interest in this Linux operating system command discussion. This is raw command line talk but it can also be supervised as a useful component tool by, (amongst other ideas by) …

  • web server side language supervision … eg. via PHP exec for example, or via curl (of that PHP)
  • called by compiled desktop program, such as Java, C++, C
  • called by a Linux/Unix shell script … in Bourne Shell, Korn Shell, C Shell, tcsh, Unix Shell

Previous relevant data from PHP/Javascript/HTML Google Chart JSON Data Table Import of CSV Tutorial is shown below.

PHP/Javascript/HTML Google Chart JSON Data Table Import of CSV Tutorial

PHP/Javascript/HTML Google Chart JSON Data Table Import of CSV Tutorial

Here is a tutorial that introduces you to Google Graphs API, or Google Chart Tools, and its JSON Data Table functionality.

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.

Thanks to the World Bank for some statistics which helped a lot.

Let’s see some PHP 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 PHP/Javascript/HTML Google Chart Intensity Map Tutorial shown below.

Link to Google Chart Tools “spiritual home” … via Google.
Link to Google Chart Tools JSON Data Table information … via Google.

Link to some downloadable PHP programming code … rename to chart_editor_in.php.
Link to some downloadable PHP programming code … rename to json_data_table.php.
Link to some downloadable input CSV data … rename to Google_Chart_Intensity_Chart_Tutorial_as.CSV.


Previous PHP/Javascript/HTML Google Chart Intensity Map Tutorial below …

PHP/Javascript/HTML Google Chart Intensity Map Tutorial

PHP/Javascript/HTML Google Chart Intensity Map Tutorial

Here is a tutorial that introduces you to Google Graphs API, or Google Chart Tools, and its Intensity Map functionality.

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.

Thanks to the World Bank for some statistics which helped a lot.

Let’s see some PHP code in live action for this tutorial where you define your intensity map characteristics and data.

Now part of an Android App called Geo Chart++ in July 2013.

Link to Google Chart Tools “spiritual home” … via Google.
Link to Google Chart Tools Intensity Map information … via Google.

Link to some downloadable PHP programming code … rename to intensity_chart.php.

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

This entry was posted in eLearning, Operating System, Tutorials and tagged , , , , , , . Bookmark the permalink.

34 Responses to Windows Command Line Interactive sort Tutorial

  1. Ppob Terbaik says:

    Very nice info and right to the point. I am not sure if this is in fact the best place to ask but do you guys have any ideea where to employ some professional writers? Thank you :)

  2. Katie says:

    Witaj, fajny wpis. Pewien czas nie pisaΕ‚em tak interesujΔ…cego tekstu

  3. You made a number of nice points there. I did a search on the topic and found a good number of persons will agree with your blog.

  4. Furniture says:

    Wonderful goods from you, man. I’ve understand your stuff previous to and you are just extremely excellent. I really like what you’ve acquired here, really like what you are saying and the way in which you say it. You make it entertaining and you still care for to keep it sensible. I can’t wait to read far more from you. This is actually a tremendous website.

  5. Shag Carpet says:

    I think other web site proprietors should take this web site as an model, very clean and wonderful user genial style and design, as well as the content. You are an expert in this topic!

  6. Branding says:

    Thanks so much for providing individuals with an extraordinarily brilliant possiblity to read in detail from here. It is often very enjoyable and jam-packed with a great time for me personally and my office friends to search your web site on the least thrice every week to read through the new tips you will have. Of course, I am also at all times amazed with your remarkable solutions served by you. Some 2 facts in this post are absolutely the most efficient I have ever had.

  7. Garden Ideas says:

    Wow! Thank you! I always needed to write on my site something like that. Can I take a fragment of your post to my site?

  8. New Homes says:

    It‘¦s actually a nice and useful piece of information. I am satisfied that you simply shared this helpful information with us. Please keep us informed like this. Thanks for sharing.

  9. Wow, marvelous weblog structure! How lengthy have you ever been blogging for? you make blogging look easy. The whole glance of your site is wonderful, let alone the content material!

  10. I just wanted to write a quick note to be able to appreciate you for some of the unique steps you are showing at this site. My time-consuming internet search has at the end of the day been paid with wonderful know-how to talk about with my friends. I ‘d believe that we visitors are really fortunate to exist in a very good place with very many brilliant individuals with helpful hints. I feel rather lucky to have used your entire webpages and look forward to plenty of more thrilling moments reading here. Thanks once again for a lot of things.

  11. Keep working ,impressive job!

  12. Great web site. Lots of helpful info here. I am sending it to a few buddies ans also sharing in delicious. And of course, thanks for your effort!

  13. best invisible fence says:

    Enjoyed looking at this, really great stuff, regards .

  14. Self Development Audio Books says:

    This net web page is normally a walk-through just like the information you preferred in regards to this and didn’t know who need to have to. Glimpse right here, and you will absolutely uncover it.

  15. You could definitely see your skills in the work you write. The arena hopes for even more passionate writers like you who are not afraid to mention how they believe. Always follow your heart.

  16. Definitely believe that which you stated. Your favorite justification appeared to be on the net the easiest thing to be aware of. I say to you, I definitely get annoyed while people consider worries that they just don’t know about. You managed to hit the nail upon the top and defined out the whole thing without having side effect , people could take a signal. Will likely be back to get more. Thanks

  17. It‘¦s really a great and useful piece of information. I‘¦m glad that you just shared this helpful information with us. Please stay us up to date like this. Thanks for sharing.

  18. Orthodontist says:

    It’s perfect time to make some plans for the future and it’s time to be happy. I’ve read this post and if I could I wish to suggest you some interesting things or advice. Perhaps you can write next articles referring to this article. I want to read more things about it!

  19. There is apparently a bundle to know about this. I think you made certain nice points in features also.

  20. Have you ever considered writing an ebook or guest authoring on other websites? I have a blog based on the same information you discuss and would love to have you share some stories/information. I know my viewers would value your work. If you are even remotely interested, feel free to shoot me an email.

  21. House Search says:

    There is visibly a lot to identify about this. I believe you made certain good points in features also.

  22. health news says:

    I‘¦m now not positive the place you’re getting your information, but great topic. I must spend a while studying much more or figuring out more. Thank you for magnificent information I used to be on the lookout for this info for my mission.

  23. Well I truly liked reading it. This tip provided by you is very practical for good planning.

  24. I get pleasure from, result in I discovered just what I was having a look for. You have ended my 4 day long hunt! God Bless you man. Have a great day. Bye

  25. Subtle says:

    Simply wish to say your article is as astonishing. The clearness in your post is simply cool and i can assume you’re an expert on this subject. Fine with your permission let me to grab your RSS feed to keep updated with forthcoming post. Thanks a million and please carry on the enjoyable work.

  26. Hiya, I am really glad I’ve found this information. Today bloggers publish only about gossips and net and this is actually annoying. A good blog with exciting content, this is what I need. Thank you for keeping this web site, I will be visiting it. Do you do newsletters? Cant find it.

  27. you’re truly a excellent webmaster. The site loading pace is incredible. It sort of feels that you’re doing any distinctive trick. Furthermore, The contents are masterwork. you have performed a magnificent process in this matter!|

  28. Simply wish to say your article is as astonishing. The clarity in your post is just great and i can assume you’re an expert on this subject. Well with your permission allow me to grab your feed to keep updated with forthcoming post. Thanks a million and please carry on the rewarding work.

  29. I precisely wanted to thank you very much once again. I do not know the things that I could possibly have followed in the absence of those methods shared by you about my concern. It had been the depressing concern for me personally, however , noticing the very specialised manner you managed that forced me to jump with contentment. I am grateful for the support and then have high hopes you realize what an amazing job you have been doing teaching the others by way of your website. More than likely you’ve never come across all of us.

  30. patterns says:

    I blog quite often and I seriously appreciate your information. This great article has really peaked my interest. I will take a note of your website and keep checking for new details about once a week. I opted in for your Feed as well.|

  31. I gotta favorite this website it seems very helpful handy

  32. Thank you so much for giving everyone an extremely marvellous chance to read from this site. It is usually so enjoyable and as well , jam-packed with amusement for me and my office acquaintances to visit your website at least thrice in 7 days to study the fresh things you have. Not to mention, I’m so always impressed with your eye-popping creative concepts served by you. Some 1 ideas in this post are truly the most impressive we have had.

  33. Ada says:

    My friend and I have actually been discussing individual blog sites as well as online journaling. She really feels that individual feelings and such must not expressed in such open forums. I see no worry with it. Share your thoughts:. 1. Do you blog or journal?. 2. Do you favor in person expression of feelings over created interaction?.

    • admin says:

      Totally agree that individual feelings are nothing to do with what we are trying to do. Here it is supposed to be about imparting experience and a bit of humour, we hope. The social media sites are for the other individual feelings, and that is good for their role. Thanks for reading.

Leave a Reply to patterns Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>