-5

My file contains about 1602 elements like

 1ajith   
3abhiram  
9bijo   
2aaliya   
 etc..

I want to sort it. My desired output is:

1ajith  
2aaliya   
3abhiram    
9bijo 

Plz help me with your valuable ideas.

Santosh Ghimire
  • 3,087
  • 8
  • 35
  • 63
user3243366
  • 75
  • 1
  • 1
  • 4

1 Answers1

0

Should be something like this:

ins = open( "file.txt", "r" )
array = []
for line in ins:
    array.append( line )
ins.close()
array = sorted(array)
for line in array :
    print line
krowe
  • 2,129
  • 17
  • 19