Is there any functionality by which I can sort the contents of a file in place in windows 7 ?

I am not sure if there is any way I could do it in UI, but is there any batch script which will help me do it ?

An example of what I am trying to do.

Let file "data.txt" containing the follwing data be the input file


The output data.txt should contain


Basically, something like a natural sort.

How can I achieve this in windows 7

  • What do you mean by sort a file? Sort the contents? By what order? Or do you mean to sort the file list? How do you want to do it, programatically, or through the Windows UI?
    – Ray
    Sep 5 '11 at 13:28
  • Made the question more clear. Sep 5 '11 at 13:35
  • @cmv: You actually didn't make it any more clear. Ray's questions still stand. What exactly are you trying to do? What kind of file are you talking about? Sort it how?
    – David
    Sep 5 '11 at 13:37
  • I edited the question once more. Sep 5 '11 at 13:41

windows 7 and much older versions of windows have an exe: sort.exe it makes exactly what you want (as I understud your question) use it as:

sort <data.txt >newData.txt
  • 1
    but sort command doesn't seem to support natural sort
    – phuclv
    Apr 6 '17 at 6:28
  • result is completely wrong and not sorted (on WIn10 at least)
    – Pavel P
    Feb 2 '19 at 8:42

Start a command prompt window.

Type help sort in order to see and then enter the syntax right.

You will find that the command is sort data.txt /o newData.txt.

Check your work by entering type data.txt to display the original data, and then type newData.txt to see the sorted file contents.

  • the final command should have been type newData.txt I missed bolding the first word.
    – reigh
    Dec 17 '14 at 23:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.