I don't know how to read input array number in input.txt and write result in output.txt. Example:

input.txt have array 7 8 9 2 
write result sort in output.txt 2 7 8 9  

How can I do it?

  • " input.txt have array 7 8 9 2" is no useful information. What is that to be, different lines? Data within the same line? – Hauke Laging Apr 22 '13 at 3:17

Suppose input is in input.txt and you want output in output.txt. Make a python script and name it sort.py like this:

print l  # It will store it as a list

# or more precisely your answer can be
for i in l:
    k+=str(i)+" "
print k       #same output as you want

Run it in the terminal :

python sort.py < input.txt > output.txt

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