You just need to read in the text and split it by new lines, then use the sorted function using only the integer part of line as the key.
with open('my_text_file.txt') as textfile:
lines = textfile.read().split('\n') # ['@0 #1', '@30 #2', '@750 #2', '@20 #3', '@500 #3', '@2500 #4', '@460 #4', '@800 #1', '@2200 #1', '@290 #2', '@4700 #4', '@570 #1']
lines = sorted(lines, key=lambda i: int(i[1:i.index('#') -1])) # ['@0 #1', '@20 #3', '@30 #2', '@290 #2', '@460 #4', '@500 #3', '@570 #1', '@750 #2', '@800 #1', '@2200 #1', '@2500 #4', '@4700 #4']
txt = '\n'.join(lines)
with open('my_new_text_file.txt', 'wt') as textfile:
textfile.write(txt)
output
@0 #1
@20 #3
@30 #2
@290 #2
@460 #4
@500 #3
@570 #1
@750 #2
@800 #1
@2200 #1
@2500 #4
@4700 #4