Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function! Strcmp(...)
- let a1 = a:1
- let a2 = a:2
- if a1 =~ '^\d\+$'
- let a1 = 0 + a1
- endif
- if a2 =~ '^\d\+$'
- let a2 = 0 + a2
- endif
- if a1 == a2
- return 0
- elseif a1 > a2
- return 1
- else
- return -1
- endif
- endfunction
- function! SortWord()
- let lnum = 1
- while lnum <= line("$")
- let words = split(getline(lnum), " ")
- call sort(words, function("Strcmp"))
- call setline(lnum, join(words, " "))
- let lnum = lnum + 1
- endwhile
- endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement