Advertisement
Guest User

Untitled

a guest
May 28th, 2015
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. function! Strcmp(...)
  2. let a1 = a:1
  3. let a2 = a:2
  4. if a1 =~ '^\d\+$'
  5. let a1 = 0 + a1
  6. endif
  7.  
  8. if a2 =~ '^\d\+$'
  9. let a2 = 0 + a2
  10. endif
  11.  
  12. if a1 == a2
  13. return 0
  14. elseif a1 > a2
  15. return 1
  16. else
  17. return -1
  18. endif
  19. endfunction
  20.  
  21. function! SortWord()
  22. let lnum = 1
  23. while lnum <= line("$")
  24. let words = split(getline(lnum), " ")
  25. call sort(words, function("Strcmp"))
  26. call setline(lnum, join(words, " "))
  27. let lnum = lnum + 1
  28. endwhile
  29. endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement