Split a string, reverse the sequence and append them again
s = "order. wrong the in are words These" s.split(/(\s+)/).reverse!.join('') # => "These words are in the wrong order."