I looked at "Text Processing in Python" and tried an example on Schwartzian sorting.
I used the following structure for sample data, which also contains empty rows. I sorted this data by the fifth column:
383230 -49 -78 1 100034 '06 text '9562' text '720' text '867
335067 -152 -18 3 100030 ' text '2400' text '2342' text '696
136592 21 230 3 100035 '03. text '10368' text '1838' text '977
Code used for Schwartz sorting:
for n in range(len(lines)): # Create the transform
lst = string.split(lines[n])
if len(lst) >= 4: # Tuple w/ sort info first
lines[n] = (lst[4], lines[n])
else: # Short lines to end
lines[n] = (['\377'], lines[n])
lines.sort() # Native sort
for n in range(len(lines)): # Restore original lines
lines[n] = lines[n][1]
open('tmp.schwartzian','w').writelines(lines)
, , , . if-else, . , , ( ), .
, ? , , ?
EDIT: '\ 377'. sort(), .
else: # Short lines to end
lines[n] = (['\377'], lines[n])
print type(lines[n][0])
>>> (type 'list')
nosklo '\ 377' . !
, 2- , 0,95 0,09 , . !