Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/ruby
- # coding: utf-8
- def sort_word_in_string(s)
- a = s.split(/[ ,.]+/)
- a.sort_by {|e| e.downcase }
- end
- # test
- DATA.each_line do |line|
- puts line
- puts sort_word_in_string(line.chomp)
- end
- __END__
- a s d f g h j k l
- q,w,e,r,t,y,u,i,o,p
- z.x.c.v.b.n.m
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement