Here's the shortest I've gotten after looking at some of the comments:
IO.write$*.pop,ARGF.lines.sort.join
And yes, it does work even without the space between `write` and `$*`.
Also after testing, I realized the ('\n') is not required for join. When you call 'lines', it still has the '\n' character in the string, and when you join, it defaults to join without a delimiter, so it's putting them back together with the newline still there.
The thing is in ruby you are already in main method so there's no need to declare main function as an entry point.
The main reason that the c++ version the code is longer has some historical/performance related issues!
In c++11 it could've been with smaller standard library at design but that could break the old codes!
Although obviously, "Little code =! Better code".
What you want to achieve is actually more important.
Btw, C++ as a scripting language? at first you might think that way but truly that's a big lie :)