| Bytes | Lang | Time | Link |
|---|---|---|---|
| 056 | AWK | 250228T210912Z | xrs |
| 167 | sed 4.2.2 rz | 240708T120658Z | guest430 |
| 061 | Arturo | 240708T150511Z | chunes |
| 079 | Julia | 240628T100136Z | Glory2Uk |
| 071 | Ruby | 240628T092739Z | Glory2Uk |
| 140 | Go | 240629T144017Z | bigyihsu |
| 009 | Uiua SBCS | 240629T034250Z | chunes |
| 242 | Elisp | 240628T145230Z | Samuel J |
| 013 | K ngn/k | 220823T235407Z | Bubbler |
| 059 | Python 3 | 220823T225334Z | DLosc |
| 068 | Python | 220823T221447Z | 97.100.9 |
| 103 | Knight | 220823T214919Z | naffetS |
| 010 | BQN | 220823T182319Z | DLosc |
| 086 | C# Visual C# Interactive Compiler | 220823T053414Z | Ivan Nee |
| 003 | Pip | 220822T193744Z | DLosc |
| 001 | Vyxal s | 220822T185159Z | naffetS |
| nan | 220129T165832Z | Gabe | |
| 022 | Factor | 220129T162456Z | chunes |
| nan | 170906T141910Z | Dom Hast | |
| 049 | Jq 1.5 | 170922T152047Z | jq170727 |
| 073 | R | 170922T143518Z | user2390 |
| 029 | K oK | 170906T143701Z | mkst |
| 096 | Python 2 | 161209T164326Z | AncientS |
| 020 | TXR Lisp | 170802T150745Z | Kaz |
| 053 | Perl 5 | 170802T032236Z | Xcali |
| 075 | Python 3 | 170801T173213Z | biowease |
| 058 | Python 2 | 170416T064731Z | Keerthan |
| 195 | Oracle SQL | 170416T010800Z | Demonbla |
| 003 | Pyth | 161208T132440Z | Maltysen |
| 160 | Java | 161208T230310Z | user1893 |
| 067 | PHP | 161208T141441Z | Titus |
| 063 | PHP | 161209T105818Z | aross |
| 033 | Haskell | 161208T150728Z | Laikoni |
| 071 | C | 161208T173703Z | Jacajack |
| 055 | Bash + GNU utilities | 161208T181939Z | Digital |
| 032 | Perl 6 | 161208T160955Z | smls |
| 046 | JavaScript ES6 | 161208T155721Z | Neil |
| 006 | Actually | 161208T124731Z | Sherlock |
| 046 | JavaScript ES6 | 161208T131948Z | ETHprodu |
| 084 | C | 161208T141702Z | Karl Nap |
| 013 | J | 161208T141812Z | miles |
| 069 | Python 2 | 161208T132129Z | Kade |
| 077 | PHP | 161208T132831Z | Xanderha |
| 001 | Jelly | 161208T132152Z | lynn |
| 013 | Retina | 161208T121444Z | Martin E |
| 004 | CJam | 161208T121216Z | Martin E |
AWK, 56 bytes
{for(i=0;i++<NF;)b[i]=b[i]$i}END{for(m in b)printf b[m]}
{ # for each record
for(i=0;i++<NF;) # traverse each char
b[i] # array of strings
=b[i]$i} # append char at it's appropriate position
END{ # when out of records
for(m in b) # for elements of array
printf b[m]} # print each string
sed 4.2.2 -rz, 208 187 167 bytes
s/^|\n/\n"/g # prefix strings with "
:o # reset loop:
s/\n\."/\n"/ # remove marker
s/\n"/\n."/ # mark first string
:h # main loop:
s/([^\n]*)(.*\n\.")([^\n])(.*)/\1\3\2\4/ # move char from marked string to output
t;: # try:
s/(.*)\n\."([^\n]*)\n"(.*)/\1\n"\2\n."\3/ # move marker down 1 string
/^[^\n]*(\n\.?")*$/!{To;Th} # if (chars still present): {catch: {jump to reset loop}; jump to main loop}
s/\n.*// # clean up output
takes input as newline-separated strings (ie you can't have newlines in your strings). this version fixes bugs related to having strings which match my string-separator markers too closely, and vastly improves the control flow.
I know that's not how try-catch statements work, but that's how sed's logic flow works. let me know if there's a better way to pseudocode it.
Julia, 96, 79 bytes
- Thanks to MarcMush for golfing a whopping 17 bytes! (Note that the previous version is still available as a link to the ATO site)
-,~=length,join
!a=-a<2 ? ~a : ~[(m=map(*,a...););!SubString.(a,-m+1)[.-a.>-m]]
I have noticed that the concatenation with map(*,a...) was a good starting point: it kind of interleaves all strings of a list with certain exceptions: the list a cannot have 1 or 0 elements and the number of the interleaved characters are limited by the size of the shortest string.
Here, the interleaved piece is recursively joined with the next part of the output where already participated characters as well as the empty string get removed.
The party ends as soon as the list a has reached the length less than 2.
Not a translation, but similar to my Ruby answer.
Ruby, 86 83 71 bytes
f=->s{s[0]&&(s.reject! &:empty?;[s.map{_1[0]},f[s.map{_1[1..]}]].join)}
A rather naive approach and my first ruby golf; later I could improve using some tips from my other Ruby golf.
s.reject! &:empty?removes all empty strings from the array;s.map{_1[1..]}the first letters are removed;s.map{_1[0]}and added to the output vector;whiles.length>0s[0]&&(...)the process is repeated recursively until all strings were removed and the output vector is joined to a string.
Go, 140 bytes
func(s[]string)(o string){for L,e,i,k:=len(s),0,0,0;e!=L;i++{
r:=s[i%L]
if len(r)<=k{e++;continue}
o+=r[k:k+1]
if i%L==L-1{k++;e=0}}
return}
Explanation
func(s[]string)(o string){
for L,e,i,k:=len(s),0,0,0;e!=L;i++{ // loop while the the whole slice is not "empty"
j:=i%L // get the index of the string to look at
r:=s[j] // the string to try to take from
if len(r)<=k{e++;continue} // if the current k-index is farther along than the string's length, skip it
o+=r[k:k+1] // add the first character of the string to the output
if j==L-1{k++;e=0}} // move to the next character and reset the "empty" counter if at the end of the slice
return}
Uiua SBCS, 9 bytes
⊏⍏∩/◇⊂⍚°⊏
Explanation
⊏⍏∩/◇⊂⍚°⊏
⍚°⊏ # get list of length-ranges of input
∩/◇⊂ # flatten both ranges and input
⍏ # get rise (grade up) of flattened ranges
⊏ # index into input
Port of miles' J solution.
Elisp, 242 Bytes
This is literally my first time so it could probably be smaller and it only works with two arguments (assigned to a and b)
(setq a (elt argv 0))(setq b (elt argv 1))(with-temp-buffer (insert a b)(setq i 0)(ignore-errors (while (< i (length b))(progn (goto-char (+(length a) 2 i))(transpose-chars (* -1 (- (length a) i 1)))(setq i (+ i 1)))))(princ (buffer-string)))
Ungolfed version
(setq a (elt argv 0))
(setq b (elt argv 1))
(with-temp-buffer
(insert a b)
(setq i 0)
(ignore-errors
(while (< i (length b))
(progn
(goto-char (+(length a) 2 i))
(transpose-chars (* -1 (- (length a) i 1)))
(setq i (+ i 1))
)
)
)
(princ (buffer-string))
)
But if you strip away all the boilerplate code its actually much shorter (134).
(insert a b)
(setq i 0)
(while (< i (length b))
(goto-char (+(length a) 2 i))
(transpose-chars (* -1 (- (length a) i 1)))
(setq i (+ i 1))
)
Elisp really sucks. Someone needs to modify it for golfing if haven't already.
K (ngn/k), 13 bytes
<!/,/'(!#:)'\
Port of miles's J and DLosc's BQN. For a language with flatten and grade/sort-by but not zip-longest, I guess this is one of the best possible approaches.
More straightforward port would be {(,/x)@<,/!'#'x} because K doesn't have fork or over. But it is possible to use K train by abusing repeat-scan:
<!/,/'(!#:)'\
( )'\ Given a list of strings, apply this to each list
until convergence and collect all intermediate values
(including the input):
!#: get the indices of the list
This always converges after step 1, giving (x;!#x)
,/' Flatten each
<!/ Sort first by second
Python 3, 59 bytes
f=lambda s:s and s[0][:1]+f(s[1:]+[s[0][1:]][:s[0]>""])or""
A recursive function that takes a list of strings and returns a string. Try it online!
Explanation
We're going to build the interleaved string one character at a time. There are several cases to consider:
- Is the first string in the list nonempty? Take its first character, move the rest of it to the end of the list, and recurse.
- Is the first string in the list empty? Remove it from the list and recurse.
- Is the list of strings empty? Then we're done. Return empty string.
The implementation goes as follows:
f = lambda s: s and ... or ""
Define f to be a function of one argument, s, which is a list of strings. If s is nonempty, do the ... part (see below); otherwise, return "".
s[0][:1] + f(...)
Since we now know s is nonempty, we can refer to its first element, s[0]. We don't know yet whether s[0] is empty, though. If it isn't, we want to concatenate its first character to a recursive call; if it is, we can concatenate the empty string to a recursive call. Slicing everything left of index 1 works in both cases.
s[1:] + ...
The argument to the recursive call is going to be all but the first element of s, concatenated to either a 1-element list (the rest of s[0] if it was nonempty) or an empty list (if s[0] was empty).
[s[0][1:]][:s[0] > ""]
We put s[0][1:] (the part of s[0] after the first character, which is the empty string if s[0] is empty) into a singleton list and then take a slice of that list. If s[0] is empty, s[0] > "" is False, which is treated as 0 in a slice; thus, we slice from index 0 to index 0--an empty slice. If s[0] is not empty, s[0] > "" is True, which is treated as 1; thus, we slice from index 0 to index 1--the whole 1-element list.
If lists of single-character strings can be used in place of strings, this solution can be 54 bytes:
f=lambda s:s and s[0][:1]+f(s[1:]+(s[0]and[s[0][1:]]))
Python, 68 bytes
lambda S:filter(None,chain(*zip_longest(*S))) from itertools import*
Knight, 103 bytes
;=m=iF;W=xP;=mI>mLx mLxE++"=x"=i+1i" x"W+=m-mT1;=j~1W>i=j+1j;O+G E+"x"+1jF1'\'E++++"=x"+1j"Sx"+1j"F1''"
BQN, 23 10 bytes
Massive savings by porting miles's J solution
↕∘≠¨⍋⊸⊏○∾⊢
Anonymous tacit function that takes a list of strings and returns a string. Try it at BQN online!
Explanation
↕∘≠¨⍋⊸⊏○∾⊢
¨ For each string in the argument list:
≠ Take its length
↕∘ and make a range from 0 to that number (exclusive)
With that list of lists of indices as the left argument
⊢ and the original list of lists of strings as the right argument:
○∾ Flatten both lists
⊸⊏ Index into the flattened string using
⍋ the grade-up of the flattened list of indices
Grade up, for those unfamiliar with APL-related languages, is an operation that takes a list and returns a permutation of its indices, such that if the items in the list were reordered according to the order of the indices, the list would become sorted ascending. For example:
Indices: 0 1 2 3 4 5
List: 3 1 4 1 5 9
Grade up: 1 3 0 2 4 5
Sorted: 1 1 3 4 5 9
This operation is useful for sorting one list according to the values of another list, as seen in the above solution.
C# (Visual C# Interactive Compiler), 86 bytes
a=>a.SelectMany(b=>b.Select((c,i)=>(i,c))).OrderBy(b=>b.i).Aggregate("",(s,x)=>s+x.c);
Pip, 3 bytes
WVg
The WV (weave) builtin does exactly this. It's commonly used as a binary operator to weave two iterables together, but it can also be used as a unary operator to weave a list of iterables together. Here, g is the list of command-line arguments.
Python3 -66
Python3 version of this one:
lambda*m:''.join(map(lambda*r:''.join([_f for _f in r if _f]),*m))
A super golfed version:
exec(bytes('慬扭慤洪✺⸧潪湩洨灡氨浡摢⩡㩲✧樮楯⡮彛潦晟椠晩张嵦Ⱙ洪⤩','u16')[2:])
Perl 5, + -0n 24 bytes
1while s/^./!print$&/gem
Explanation
-0n slurps the input into $_ and repeatedly replaces the first char of each line with the result of negating the print of each match (which is the empty string since print returns 1 by default)
Jq 1.5, 49 bytes
map(explode)|transpose|map(map(values)[])|implode
Explanation
# example input: ["LYES","APRONS"]
map(explode) # make list of ordinals [[76,89,69,83],[65,80,82,79,78,83]]
| transpose # zip lists [[76,65],[89,80],[69,82],[83,79],[null,78],[null,83]]
| map(map(values)[]) # rm nulls and flatten [76,65,89,80,69,82,83,79,78,83]
| implode # convert back to string "LAYPERSONS"
Sample Run
$ paste input <(jq -Mrc 'map(explode)|transpose|map(map(values)[])|implode' input)
["SIMPLE"] SIMPLE
["POLLS","EPEES"] PEOPLELESS
["LYES","APRONS"] LAYPERSONS
["ABCDE", "a c", "123 567"] Aa1B 2Cc3D E567
["\"\\n$?*", "", ",(.)\" "] ",\(n.$)?"*
$ echo -n 'map(explode)|transpose|map(map(values)[])|implode' | wc -c
49
R, 73 bytes
for(i in 1:max(nchar(s<-scan(,""))))for(j in seq(s))cat(substr(s[j],i,i))
Explanation: very simple (but verbose), just loop through printing ith character of the jth string. Fortunately, substr returns an empty string if given an out-of-range input.
K (oK), 35 29 bytes
Solution:
{`c$r@&~^r:,/+(`i$x)[;!#,/x]}
Example:
> {`c$r@&~^r:,/+(`i$x)[;!#,/x]}("ABCDE";"a c";"123 567")
"Aa1B 2Cc3D E567"
> {`c$r@&~^r:,/+(`i$x)[;!#,/x]}("\n$?*";"";",(.)\" ")
"\n,$(?.*)\" "
> {`c$r@&~^r:,/+(`i$x)[;!#,/x]}("POLLS";"EPEES")
"PEOPLELESS"
Explanation:
Use 2nd-level indexing to pull out indices from 0 to max (length of flattened list) across all input lists. Any indexing beyond the bound of the sub-list will return a null. Flip (rotates 90), flatten, and then pull out the non-null results.
Notes:
- I cast to integer (
i$) so that we get useful nulls, as space () is considered null for a char list which means you cant tell nulls from valid spaces. - Also I couldnt get the TIO to work with input (worked fine in the oK repl) so the TIO link includes the "ABCDE"... example.
Python 2, 128 96
I was hoping not to have to use itertools
a=lambda a:"".join([i for i in reduce(lambda: b,c:b+c, map(None,*map(lambda m:list(m),a)) if i])
Ungolfed
a=lambda a: #Start a lambda taking in a
"".join( #Join the result together with empty string
[i for i in reduce( #For every item, apply the function and 'keep'
lambda: b,c:b+c, #Add lists from...
map(None,*map( #None = Identity function, over a map of...
lambda m:list(m), a) #list made for mthe strings m
) if i #truthy values only (otherwise the outer map will padd with None.
])
TXR Lisp, 20 bytes
(opip weave cat-str)
Run:
1> (opip weave cat-str)
#<intrinsic fun: 0 param + variadic>
2> [*1 "LYES" "APRONS"]
"LAYPERSONS"
3> [*1 "ABCDE" "a c" "" "123 567"]
"Aa1B 2Cc3D E567"
4> [*1 "\"\\n$?*" "" ",(.) "]
"\",\\(n.$)? *"
The weave function is lazy, so it returns a list, which is why we have to force the result to a string. Being lazy, it can weave infinite sequences. For instance, we can weave the even and odd natural numbers, which are themselves infinite lazy lists:
5> (take 20 (weave (range 2 : 2) (range 1 : 2)))
(2 1 4 3 6 5 8 7 10 9 12 11 14 13 16 15 18 17 20 19)
Perl 5, 53 bytes
$i=0,map{push@{$a[$i++]},$_}/./g for<>;print@$_ for@a
Method
Creates a two dimensional array where the number of rows is equal to the length of the longest string and the maximum number of columns is equal to the number of strings. Then output each row of the array without spacing.
Python 3, 75 Bytes
I know the other Python one is shorter, but this is the first time I've used map ever in my life so I'm pretty proud of it
lambda n:''.join(i[k]for k in range(max(map(len,n)))for i in n if len(i)>k)
Oracle SQL, 195 bytes
select listagg(b,'') within group(order by l,o) from(select substr(a,level,1) b,level l,o from i start with length(a)>0 connect by prior a=a and level<=length(a) and prior sys_guid() is not null)
Takes its input from a table named i with columns a (containing the string) and o (order of the string):
create table i (a varchar2(4000), a integer)
Explanation:
We're exploiting CONNECT BY to break up the strings into each of the characters making them up. PRIOR SYS_GUID() being NOT NULL ensures we don't end up stuck in a loop.
We then concatenate the single characters with LISTAGG but we shuffle them around with an ORDER BY clause, ordering them first by their position in the original string and only then by the string they came from.
Not as short as the other answers but SQL isn't really meant as a string manipulation language :)
Pyth - 3 bytes
Very simple, will add expansion later, on mobile.
s.T
s Join all the strings together
.T Transpose, without chopping off overhang
(Q implicit)
Java, 19+155=174 160
String f(java.util.Queue<String> q){String s,r="";while(!q.isEmpty()){s=q.poll();r+=s.isEmpty()?"":s.charAt(0);if(s.length()>1)q.add(s.substring(1));}return r;}
Ungolfed:
String f(java.util.Queue<String> q) {
String s, r = "";
while (!q.isEmpty()) {
s = q.poll();
r += s.isEmpty() ? "" : s.charAt(0);
if (s.length() > 1) {
q.add(s.substring(1));
}
}
return r;
}
Output:
SIMPLE
PEOPLELESS
LAYPERSONS
Aa1B 2Cc3D E567
",(n.$)?"*
First modification: merged string declaration to save some bytes. Removed import, it was used by the main() method (not shown here) that also needed LinkedList. It is fewer bytes to referece Queue directly.
PHP, 68 67 bytes
for(;$f=!$k=$f;$i++)for(;y|$v=$argv[++$k];$f&=""==$c)echo$c=$v[$i];
Loops over command line arguments. Run with -r.
After the inner loop, $f is 1 when all strings are finished, 0 else (bitwise & casts ""==$c to int).
Next iteration of the outer loop: copy $f to $k (saves one byte from $k=0) and toggle $f:
When all strings are done, $f is now false and the loop gets broken.
PHP, 63 bytes
Note: uses IBM-850 encoding
for(;$s^=1;$i++)for(;n|$w=$argv[++$$i];$s&=$x<~■)echo$x=$w[$i];
Run like this:
php -r 'for(;$s^=1;$i++)for(;n|$w=$argv[++$$i];$s&=$x<~■)echo$x=$w[$i];' "\"\n\$?*" "" ",(.)\" " 2>/dev/null;echo
> ",\(n.$)?"*
Explanation
for( # Iterate over string index.
;
$s ^= 1; # Continue until $s (stop iterating) is 1.
# Flip $s so each iteration starts with $s
# being 1.
$i++ # Increment string index.
)
for(
;
"n" | $w=$argv[++$$i]; # Iterate over all input strings. OR with "n"
# to allow for empty strings.
$s &= $x<~■ # If last character printed was greater than
# \x0 (all printable chars), set $s to 0,
# causing the loop to continue.
)
echo $x = $w[$i]; # Print char $i of current string.
Haskell, 33 bytes
import Data.List
concat.transpose
Try it on Ideone. Usage:
Prelude Data.List> concat.transpose$["ABCDE","a c","123 567"]
"Aa1B 2Cc3D E567"
Without using a build-in: (38 34 bytes)
f[]=[]
f x=[h|h:_<-x]++f[t|_:t<-x]
Try it on Ideone. 4 bytes off thanks to Zgarb! Usage:
Prelude> f["ABCDE","a c","123 567"]
"Aa1B 2Cc3D E567"
C, 75 71 bytes
Only limitation is the output length. Currently it's 99, but can be easily stretched to 999 (+1 byte).
i;main(a,b)char**b;{a--;for(;i<99;i++)*b[i%a+1]&&putchar(*b[i%a+1]++);}
Ungolfed:
i;
main( a, b )
char **b;
{
a--;
for( ; i < 99; i++ )
*b[i % a + 1] && putchar( *b[i % a + 1]++ );
}
Bash + GNU utilities, 55
eval paste `sed "s/.*/<(fold -1<<<'&')/g"`|tr -d \\n\\t
I/O via STDIN (line-separated) and STDOUT.
The sed formats each line to a bash process substitution. These are then evaled into paste to do the actual interleaving. tr then removes unnecessary newlines and tabs.
Perl 6, 34 32 bytes
{[~] flat roundrobin |$_».comb}
{roundrobin(|$_».comb).flat.join}
A lambda that takes an array of strings as argument, and returns a string.
JavaScript (ES6), 46 bytes
f=([[c,...s],...a])=>c?c+f([...a,s]):a+a&&f(a)
<textarea oninput=o.textContent=f(this.value.split`\n`)></textarea><div id=o>
Actually, 7 6 bytes
Golfing suggestions welcome! Try it online!
Edit: -1 byte thanks to Teal pelican.
a Z♂ΣΣ
Ungolfing
Implicit input each string.
a Invert the stack so that the strings are in the correct order.
<space> Get the number of items on the stack, len(stack).
Z Zip all len(stack) strings into one, transposing them.
♂Σ sum() every transposed list of chars into strings.
Σ sum() again to join the strings together.
JavaScript (ES6), 52 46 bytes
f=([[c,...s],...a])=>s+a?c+f(s+s?[...a,s]:a):c
Takes input as an array of strings and outputs as a single string.
Test snippet
f=([[c,...s],...a])=>s+a?c+f(s+s?[...a,s]:a):c
g=a=>console.log("Input:",JSON.stringify(a),"Output:",JSON.stringify(f(a)))
g(["SIMPLE"])
g(["POLLS","EPEES"])
g(["LYES","APRONS"])
g(["ABCDE","a c","123 567"])
g(["\"\\n$?*",",(.)\" "]) // Backslash and quote are escaped, but in/output are correct
C, 114 84 bytes
-20 bytes for not calculating the length.
i,b;f(char**s){b=1;while(b){i=-1;b=0;while(s[++i]>0)if(*s[i])putchar(*s[i]++),++b;}}
Accepts array of char pointers and requires last item to be a null-pointer (see usage).
Ungolfed and usage:
i,b;f(char**s){
b=1;
while(b){
i=-1;
b=0;
while(s[++i]>0)
if(*s[i])
putchar(*s[i]++),++b;
}
}
int main(){
char*a[]={
// "POLLS","EPEES"
// "LYES","APRONS"
"ABCDE","a c","123 567"
,0};
f(a);
puts("");
}
J, 13 bytes
({~/:)&;#\&.>
Based on the inspiration for this question.
Another way to do it takes 27 bytes but operates using transpose. Most of the bytes are to handle the automatically added zeroes from padding.
[:u:0<:@-.~[:,@|:(1+3&u:)&>
Explanation
({~/:)&;#\&.> Input: list of boxed strings S
&.> For each boxed string x in S
#\ Get the length of each prefix from shortest to longest
This forms the range [1, 2, ..., len(x)]
Rebox it
( ) Operate on S and the prefix lengths
&; Raze both
/: Grade up the raze of the prefix lengths
{~ Index into the raze of S using the grades
Return
Python 2, 101 89 86 69 bytes
I'm hoping I can get this into a lambda somehow, shortening it down by making it recursive. It isn't ideal because you would hope transposing is shorter, unfortunately it isn't (from what I have managed to come up with so far).
f=lambda s:' '*any(s)and''.join(x[:1]for x in s)+f([x[1:]for x in s])
Old solutions:
w=input();o=''
while any(w):
for i in range(len(w)):o+=w[i][:1];w[i]=w[i][1:]
print o
lambda s:''.join(''.join([c,''][c<' ']for c in x)for x in map(None,*[list(y)for y in s]))
w=input();o=''
while any(x>=' 'for x in w):
for i in range(len(w)):o+=w[i][:1];w[i]=w[i][1:]
print o
thanks to mathmandan for making me feel dumb ;) saved me a bunch of bytes! (on an old solution)
PHP, 77 bytes
Golfed
function($a){for($d=1;$d!=$s;$i++){$d=$s;foreach($a as$v)$s.=$v[$i];}echo$s;}
Anonymous function that takes an array of strings.
I'm sure this could be golfed more, but it's early. On each iteration, we grab the i-th letter from each given string and append it to our final string, one at a time. PHP just throws warnings if we access bits of strings that don't exist, so that's fine. We only stop when no changes have been made after looping through all the strings once.
I feel like the usage of $d can be golfed more, but it's early. :P
Retina, 13 bytes
Byte count assumes ISO 8859-1 encoding.
O$#`.
$.%`
¶
Explanation
O$#`.
$.%`
This is based on the standard transposition technique in Retina. We sort (O) all non-linefeed characters (.), by ($#) the number of characters in front of them on the same line ($.%`), i.e. their horizontal position.
The second stage then simply removes linefeeds from the input.
CJam, 4 bytes
qN/z
We can also write an unnamed function for 4 bytes, which expects a list of strings on top of the stack:
{zs}