To find the kth longest word in a string in Ruby, you can take the following approach:
split methodsort_by method and the length attributeHere's the code that implements this logic:
main.rb322 chars11 linesYou can call this method with a string and the kth value to get the kth longest word:
main.rb197 chars5 lines
gistlibby LogSnag