Hello. I am have a problem while trying to write to a file some sorted lines . my initial file is somthing like this
name2,number2;name3,number3;name1,number1
when i run this code

ord = open("Be.csv", 'r')
order = ord.read().split(";")
order = sorted(order)
for sort in order:
print sort
ord.close()
f=open("Odd.csv","w")
f.write(sort)
f.close()

Even if it prints in shell all the lines i want and of course sorted in the new file it will only write name3,number3
What might seem to be the problem?
if someone has any ideea i would be grateful.

  • created

    Mar '11
  • last reply

    Mar '11
  • 1

    reply

  • 908

    views

  • 2

    users

You iterate over order with sort. So sort after for loop is just last element of your sorted list order.