Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # offsetsorting.py
- import re
- def remove_digits(z):
- return re.sub('[0-9 \-\?\+\t]', '', z)
- zzz='''
- qqq
- - www
- 1 eee
- ++ rrr
- 2 ttt
- - yyy
- uuu
- 7 iii
- ++ ooo
- 9 ppp
- - aaa
- - sss
- ddd
- ++ fff
- 6 ggg
- hhh
- - jjj
- ++ kkk
- ++ lll
- ++ zzz
- 3 xxx
- 8 ccc
- 5 vvv
- ++ bbb
- nnn
- - mmm
- '''.splitlines()
- zzz = set(zzz)
- zzz = sorted(zzz, key=lambda s: (remove_digits(s), s))
- zzz = '\n'.join(zzz)
- zzz = re.sub(r'[\t ]{2,}', '\t'*2, zzz)
- print zzz
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement