31
1
Sort the Textbooks
School is starting soon (if it hasn't already) and so it's time to get our textbooks in order. You need to sort your books in alphabetical order but that takes too long so you decide to write a program to do it.
Examples
Input:
_
| | _
|F| | |
|o|_|P|
|o|B|P|
| |a|C|
| |r|G|
|_|_|_|
Output:
_
| |_
|F| |
_|o|P|
|B|o|P|
|a| |C|
|r| |G|
|_|_|_|
Input
The input will be a set of books which need to rearranged alphabetically. It will contain only: |
, _
, , and
A-Za-z
. The titles of the books are read vertically, top-bottom.
You may choose to assume the input is padded with whitespace to fit a rectangle. If you choose to have your input padded with whitespace, please specify this in your answer.
The very maximum book height your program will need to handle is 5,120 lines tall without failing.
The books will always be 1-thick and their will always be at least one book in the input
Output
The output will need to be the same set of books organized in alphabetical order. The height of the books must stay the same and the title must have the same spacing from the top when re-arranged.
Books should be sorted alphabetically. If your language sports a sort function you can use that. Otherwise you can use alphabetical sorting as described here.
Book Title Examples
_
| |
| |
|F|
|o|
|o|
| |
| |
|B|
|a|
|r|
| |
| |
|_|
This books title is:
"Foo Bar"
Book titles will only contain letters and spaces.
Trailing whitespace is allowed
Winning
This is code-golf so shortest code in bytes wins.
Is there a limit to the "height" of the books? – The_Basset_Hound – 2015-08-05T00:55:07.190
@BassetHound No, there currently isn't but don't need to worry about supporting books 2^64-1 tall. I'll put a maximum at 5,120 "tall" is what your program needs to handle without failing – Downgoat – 2015-08-05T00:56:32.253
Alright, great. – The_Basset_Hound – 2015-08-05T00:57:38.927
@ETHproductions Yes, book titles will only contain letters and spaces – Downgoat – 2015-08-05T01:08:02.697
You've changed the rules on sorting quite a few times, so just to make sure - does "If your language sports a sort function you can use that." mean that alphabetical sorting is optional and we can use our language's own sort function (which typically compares ASCII codes and puts capital letters before lowercase and spaces before both), or is alphabetical sorting mandatory (and if so what happens with spaces?). – Sp3000 – 2015-08-05T06:56:56.907
1What about the thickness of books? Always 1 column? – coredump – 2015-08-05T08:14:44.640
Minimum number of books? 1? 2? – Martin Ender – 2015-08-05T10:50:26.537
Is there a difference between (assume _ is a space character) "Foo_Bar" and "Foo__Bar" (one versus two spaces between words)? Your example has two spaces, and I just wonder if it's significant. – Brian J – 2015-08-05T14:13:39.267
@BrianJ Yes spaces are significant – Downgoat – 2015-08-05T15:10:56.627
@MartinBüttner Their will always be atleast 1 book. – Downgoat – 2015-08-05T15:11:28.750
@coredump yes, all books will be one column – Downgoat – 2015-08-05T15:11:51.777
@Sp3000 yes, you may use your language's sort function even if it doesn't sort alphabetically – Downgoat – 2015-08-05T15:12:52.927