[Question]
  [
\* and don't have a word processor with top-left align support :D
Take several lines of input, with at least four unique characters of your choice including newline and space. The input can also be taken as a space-padded matrix of characters. Squash it upwards, then squash it left. Output this, with any amount of trailing newlines and spaces.
## To squash upwards
For any non-space character "below" a space, swap their places, until there are no more non-space characters below spaces.
## To squash left
For each line, remove all spaces.
## Example (with `abcdefghjkl \n`):
With the input (STDIN, function arguments, [etc](https://codegolf.meta.stackexchange.com/questions/2447/default-for-code-golf-input-output-methods).):
```
a b c d  e
ff ggg h i
 jj kk lll
```
Squash upwards:
```
afbgcgdhle
fjj gk l i
    k    l
```
Squash left:
```
afbgcgdhle
fjjgkli
kl
```
Output this text. (STDOUT, function return value, [etc](https://codegolf.meta.stackexchange.com/questions/2447/default-for-code-golf-input-output-methods).)
## More examples
```
input
=>
output
-------
a b c
=>
abc
-------
a
 
c
=>
a
c
-------
 
=>
------- ^ note that trailing spaces are allowed so a single line with a space is valid here
a
=>
a
-------
  
 a
=>
a
-------
ab
c
=>
ab
c
-------
abc
d e
f g
=>
abc
de
fg
-------
abc
d
f g
=>
abc
dg
f
```
---
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), shortest answer in bytes per language wins.
---
Finding out which academic journal requires submissions to be top-left aligned is left as an excercise for the reader.
  
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 11 [bytes](https://github.com/abrudz/SBCS)
```
~∘' '⍤1∘⍉⍣2
```
[Try it online!](https://tio.run/##bc6xCsIwEAbgvU/xb5k61OITuOhqfYE0NdE2oKuLi1BUSNFBcNdRcPEJfJR7kXilhUrpEi7ff3ec3Now20m7Md7v6XgXEOSeEVfkTuQeI6@pvJCr6Hwg9yL3@b5jKq9U3ZL5hN/FdJZ4DSYhkUIhA5a8RWsYY7DCmj/IcxQFrLUiEGEYikAjwhi8Ds1Y5zEnrav/7lYxYLKz@g7UXeihTBlV3xRj1twLMxi20Q8 "APL (Dyalog Unicode) – Try It Online")
A train taking and returning a character matrix.
```
         ⍣2  ⍝ repeat 2 times:
        ⍉    ⍝ transpose the character matrix
~∘' '        ⍝ remove spaces
     ⍤1      ⍝ in each row
             ⍝ each row is padded with spaces to keep the matrix shape
```
---
# [APL (Dyalog Extended)](https://github.com/abrudz/dyalog-apl-extended), 8 [bytes](https://github.com/abrudz/SBCS)
-2 bytes thanks to [Bubbler](https://codegolf.stackexchange.com/users/78410/bubbler)!
In the extended variant `⌂` provides easy access to the [*dfns* namespace](http://dfns.dyalog.com/n_contents.htm), which has a function to **d**rop **a**ll **b**lanks.
```
⌂dab∘⍉⍣2
```
[Try it online!](https://tio.run/##bc49CsJAEAXgPqd43VZbqHgCG22NF9hkfzRZ1MJCW4Wg4gYtBHtbwcYTeJS5SNyQQCSkGZjvzQwj1pbLnbArw9V2o5ZSyaKgy16KiI4Pcidyz36hKbuSy@l8IPci9/m@B5TdKL@H05Gvs/EkLDQ8MYEIMSSgGJjWMMZgjoVvkCRIU1hrWcA45yzQ6GEIfw7VWuMDn9Qe/0/Xig4TjZV/oJxCC0XkMW5b7FFW/8J0hnX0Aw "APL (Dyalog Extended) – Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 5 bytes
```
Zḟ€⁶Z
```
[Try it online!](https://tio.run/##ATsAxP9qZWxsef//WuG4n@KCrOKBtlr/4bu0w4dZ//9hIGIgYyBkICBlCmZmIGdnZyBoIGkKIGpqIGtrIGxsbA "Jelly – Try It Online")
```
Zḟ€⁶Z  Main Link
Z      Transpose the matrix
 ḟ     Filter out
  €    From each row
   ⁶   Spaces
    Z  Transpose the matrix
```
[Answer]
# [J](http://jsoftware.com/), 14 bytes
```
-.&' '"1@|:^:2
```
[Try it online!](https://tio.run/##Vc29CsIwGIXh/buKQwdDwYTaMVIQBCcn9yppfpsEdKjg4L3HqDg4nO19OLE0gjkMEgxrdJB1XGB/Oh4KFysG1mx2T3mWfWlJ6eWu8iDgMG7Fpcf4Fh0pTNAwgCXn4L1HwEyIESkh50wt2cfN6sWaiv@pm7z2JuRKY/Qpz5Q@vQ5XfP/AJX68vAA "J – Try It Online")
Not surprising, but what I came up with is almost identical to ovs's APL approach.
## how
Transpose `|:` and remove spaces `-.&' '` on each line `"1` two times `^:2`.
[Answer]
# [Python 3](https://docs.python.org/3/), 68 bytes
```
lambda x,g=lambda x:[sorted(r,key=' '.find)for r in zip(*x)]:g(g(x))
```
[Try it online!](https://tio.run/##NYw7DoMwFAR7n2JFw3OEaNIhcZIkhYk/POzYlnEBuTyBIt1IM7t5r3OK98OOzyOoz6QVts6NfxweayrVaCqdN/vYou0tRy1tKijgiC9num3yNThytEl5XIYvY6lpGoUJb2jACGvhnMMMFlgWeI8Qwpn0aw5cA0ezkpSDQC4c6znul8SR@Pz8AQ "Python 3 – Try It Online")
-15 bytes thanks to dingledooper
[Answer]
# [Red](http://www.red-lang.org), 108 bytes
```
func[x][loop 2[x: collect[while[x/1/1][keep pad trim/all form collect[forall x[keep take x/1]]length? x]]]x]
```
[Try it online!](https://tio.run/##dY4xbsQgEEV7n@KL3rI25UpJ7pAWTYFhwKxnbcshCrd3sPGutEVE8/@bh2ZWdtsXO02Nv27@Z7I6k5Z5XvCm8xV2FmGb9O8QhXXuLt2F9Mi8YDEOaY33zojAz@v96Zays1y9ZEZG@UgkPIU0fCITUaataGzsgMTfCbrRyqCHhQNYQXmPEAIGxFJwu2EcISKKHmJN@7C82nCyIx@Dmk2/K@e0t6W4ugPhheHJCn2cJ3Hi88ZljVM6AKFm9f6hmhfT/@@2bato@wM "Red – Try It Online")
Takes input and returns output as a series of strings space-padded to equal length.
[Answer]
# [MATL](https://github.com/lmendo/MATL), 7 bytes
```
,c!Z{Xz
```
[Try it online!](https://tio.run/##y00syfn/XydZMao6our//2j1RIUkhWSFFAWFVHVrBfW0NIX09HSFDIVMEE8hK0shO1shJydHPRYA) Or [verify all test cases](https://tio.run/##y00syfmf8F8nWTGqOqLqf6y6LgSoR7iE/FdPVEhSSFbnilZPVLdWUFcAEcnqsVzq6lxAES51hUSwXBJYXAEoAeIkqysAuSkKqWA6TSEdTVwBIQ4A).
Input is a char matrix (rectangular char array).
### Explanation
```
,      % Do twice
  c    %   Convert to char. The first time this takes the input (implicit),
       %   and does nothing because the input is already a char matrix. The second
       %   time this transforms the cell array of char vectors at the top of the
       %   stack into a char matrix, right-padding each line with space
  !    %   Transpose
  Z{   %   Convert char matrix into cell array of its rows
  Xz   %   Remove space from each char vector contained in that cell array
       % End (implicit)
       % Display (implicit)
```
[Answer]
# [K (ngn/k)](https://bitbucket.org/ngn/k), 14 bytes
```
2{{x@<^x}'+x}/
```
[Try it online!](https://tio.run/##y9bNS8/7/z/Nyqi6usLBJq6iVl27olb/f5qChlKiQpJCskKKgkKqkrVSWppCenq6QoZCJpCjkJWlkJ2tkJOTo6T5HwA "K (ngn/k) – Try It Online")
* `2{...}/` set up a do-reduce, running the code in `{...}` twice
	+ `{...}'+x` call the nested `{...}` with each item of the transposed input
		- `{x@<^x}` shuffle spaces to the end
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 6 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
```
Õ¸¬Õ¸¬
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=1bis1bis&input=ImEgYiBjIGQgIGUKZmYgZ2dnIGggaQogamoga2sgbGxsIg)
```
Õ¸¬Õ¸¬     :Implicit input of string
Õ          :Transpose
 ¸         :Split on spaces
  ¬        :Join
   Õ¸¬     :Repeat
```
# [Japt](https://github.com/ETHproductions/japt) [`-h`](https://codegolf.meta.stackexchange.com/a/14339/), 6 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
```
2Æ=Õ¸¬
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&flags=LWg&code=MsY91bis&input=ImEgYiBjIGQgIGUKZmYgZ2dnIGggaQogamoga2sgbGxsIg)
```
2Æ=Õ¸¬     :Implicit input of string U
2Æ         :Map the range [0,2)
  =        :  Reassign to U
   Õ       :  Transpose
    ¸      :  Split U on spaces
     ¬     :  Join
           :Implicit output of last element
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 6 bytes
Input and output is a list of lists of characters.
```
2FζðδK
```
[Try it online!](https://tio.run/##yy9OTMpM/V/zqGlN8H8jt3PbDm84t8X7f6zXod3/ExWSFJIVUhQUUrnS0hTS09MVMhQyuRSyshSysxVycnIA "05AB1E – Try It Online") or [Try all cases!](https://tio.run/##yy9OTMpM/X9o2aEVSlzWXEqHFpZVHtp2aOGjpjXB/43czm07vOHcFu//sZpeQJFDu8FqDu/9r6SkxJWokKSQrJCioJDKlZamkJ6erpChkMmlkJWlkJ2tkJOTA1QKVgKiuRS4QLQCmA2kFbgUQHRiElg4MSmZKwVkjEI6jAdmA20BAA)
`2F` iterate two times:  
`ζ` tranpose the list of lists, padding shorter lists with spaces  
`ðδK` remove all spaces
[Answer]
# [Vyxal](https://github.com/Lyxal/Vyxal) `aj`, 7 bytes
```
2(ÞTȧvṅ
```
[Try it Online!](http://lyxal.pythonanywhere.com?flags=aj&code=2%28%C3%9ET%C8%A7v%E1%B9%85&inputs=a%20b%20c%20d%20%20e%0Aff%20ggg%20h%20i%0A%20jj%20kk%20lll&header=&footer=) ([Test cases!](http://lyxal.pythonanywhere.com?flags=aj&code=2%28%C3%9ET%C8%A7v%E1%B9%85&inputs=a%20b%20c%20d%20%20e%0Aff%20ggg%20h%20i%0A%20jj%20kk%20lll&header=%40f%3A1%7C%E2%86%B5&footer=%29%E2%81%8B%2C%60-----%60%2C%3B%0A%23%20Test%20cases%0A%60a%20b%20c%20d%20%20e%0Aff%20ggg%20h%20i%0A%20jj%20kk%20lll%60%20%40f%3B%0A%0A%60a%20b%20c%60%20%40f%3B%0A%0A%60a%5Cn%20%5Cnc%60%20%40f%3B%0A%0A%60%20%60%20%40f%3B%0A%0A%60a%60%20%40f%3B%0A%0A%60%20%20%0A%20a%60%20%40f%3B%0A%0A%60ab%0Ac%60%20%40f%3B%0A%0A%60abc%0Ad%20e%0Af%20g%60%20%40f%3B%0A%0A%60abc%0Ad%0Af%20g%60%20%40f%3B))
```
2(ÞTȧvṅ    
2(         Repeat twice:
  ÞT        Transpose
    ȧ       Remove whitespace
     vṅ     Join sublists on empty string
```
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~197~~ \$\cdots\$ ~~181~~ 180 bytes
Saved a byte thanks to [a stone arachnid](https://codegolf.stackexchange.com/users/80050/a-stone-arachnid)!!!  
Saved 4 bytes thanks to [ceilingcat](https://codegolf.stackexchange.com/users/52904/ceilingcat)!!!
```
#define F for(i=0;i<l;)for(j=0,p=t[i++];*p;++p,++j)if(*p<33)for(k
i;j;k;f(t,l,p,q)char**t,*p,*q;{F=i;q=t[k]+j,k<l;)k+=*q-32?*p=*q,*q=32,l:1;F=0,q=p;!k**++q;)*q-32?*p=*q,k=*q=32:0;}
```
[Try it online!](https://tio.run/##nZVtk5owEMff@ym2dHrDQ5wqiNrL0b7o1C9xOh2NAQM5DoVObW/86rUhBIwptp1jRrPh/8vuZrNRMkwIOZ/fbmnMcgoLiJ8PNotGmD1w7NSTNBqhIqoemeetsFtgzyuQ56UOi223eAgCCWUDhlOc4diuEEcF2jtktz64boXcArl7/LKIGN4LL9nKS1FW@868yN0PA/@TWwhDQFHgI34/xgsRcB8V@E3mup63x46OZZEE70f4dGZ5BU9rltvO4GUA4pExoaJl9XX8uIIIXqw1bIDAFoBayIpjSJIEdsDEBNIUsgw459YJm8t9fXmPHrS6hcCC@quPmnTUn1qoNOgTp@3CjXQNPcisQ0jNbOsNgiU22MPOTRb62AYuG7YpIlLVUGOgxokaQzVO1ThT41y5rQ9IvuCN05L9pM@iRaRv572aumqOQNd9Q/cNPTD0wNAnhj4x9NDQQ0OfGvrU0GeGPjP0uaHPnatzoceCkopuL40abxKSbHe8Occ0TTLOoDmpjIN6rH4n/uWAbzJXLUuavu0nb7Rtp4fd5bgB/L19O8xsYdq0ZXKLN9s4UW0MRhu3Cxr8UmmkFUyzA82eaHao2VPNnmn2/CpTsqMkowcRF2Siy@MXf3n88Fl8wjpVbR60OYtfT7Dri8LyLT2KZSOszIe2n9pol47q3mDwPEk70PwE6rdZOGtutCRWuAPqcFyp4m6acrOZzbc4fuTa6y5TYCpNkSKXGejR60euZXX5n9acPxO7rA6c5rb4F1k54MHYwVe8kEnxw1bLkMSuieIgIse2tbTelUtrmYtyKloDTwMTh@FHwWpILIMg4A4260VFul3r9JWsWJelYMavKolaLIe7O6grQp6KbstUViYSTl6zcZnLgVL7v2oiHOXRvx4ZqW3oOuvW6WlwOv8iMV8n5Xn4/Tc "C (gcc) – Try It Online")
[Answer]
# [Factor](https://factorcode.org/) + `combinators.extras`, 62 bytes
```
[ [ flip [ [ 32 = ] partition prepend ] map ] twice "\n"join ]
```
[Try it online!](https://tio.run/##HY0xDsIwEAT7vGLlB1BAB6JGNDSIClI4zjlc4pyNbQQI8XaTpFntTLFrtck@lsv5eDpsYfzYsOjJpBW9c9QJiR5PEkMJA0UhB/YIkXL@hMiSsauqbwUojQYGLUBqRmvRdR3u4AXR9xgGOOdU9StXXGEdB8xls8YeNYKOmTN7mdcDSTu5UYcp84sNQd1E9Z4FdTHaOSzv5Q8 "Factor – Try It Online")
It's a quotation that accepts a matrix of characters/list of strings from the data stack as input and leaves a string on the data stack as output.
* `[ ... ] twice` Call a quotation twice.
* `flip` Transpose a matrix.
* `[ ... ] map` Do something to every row in the matrix.
* `[ 32 = ] partition prepend` Separate the spaces from the other characters, then stick 'em on one end.
* `"\n"join` Convert a matrix of code points (e.g. `{ { 91 91 32 } { 91 32 32 } { 32 32 32 } }`) to a string.
[Answer]
# [Vim](https://www.vim.org), 55 bytes
```
YP:s/./\\_./g
Dddqq:%s/\v (<C-r>-)(\S)/\2\1 
@qq@q:%s/ //g
```
Requires input to be padded to a rectangle. [Try it online!](https://tio.run/##HcrNCkBAFAbQ/TzFt1Esxo2lJMUDKCt1SxjGz2yGmte/ZH1OEBm64qGUmMeUrGqN8b6IHuKAuGz0Xekk5j4hzjmDqr2vfwZ9WWTCjAUGWNW2wVqLHYfCeeK64JwTHV4 "V (vim) – Try It Online")
### Strategy
We're going to handle the vertical swaps by constructing a regex that will match any \$n\$ characters--including newline--where \$n\$ is the length of each line. Then we look for a space followed by \$n\$ characters followed by a non-space and swap the space for the non-space. Since the potential matches of this regex are overlapping, we'll use a macro to keep on doing the replacement until there are no more matches. Then the horizontal squashing is easy: just remove all spaces.
### Explanation
```
YP
```
Copy the top line upward. We're going to turn this copy into the regex we need.
```
:s/./\\_./g<cr>
```
Replace each character on the line with `\_.`. In Vim regex, this is a construct that [matches any single character including newline](https://vi.stackexchange.com/a/13991) (TIL). Line 1 now contains a regex that matches \$n\$ characters.
```
Ddd
```
Delete to the end of the line (putting the regex in register `-`) and then delete the now-blank line (doesn't overwrite `-` because it's a multiline deletion).
```
qq
```
Begin recording macro `q`:
```
:%s/\v (<C-r>-)(\S)/\2\1 <cr>
```
Do a substitution on all lines: space, followed by the regex we stored in register `-` (group 1), followed by a non-space character (group 2) => group 2, followed by group 1, followed by space. (The `\v` sequence [means](https://vim.fandom.com/wiki/Simplifying_regular_expressions_using_magic_and_no-magic) we don't have to backslash the parentheses, saving a net 2 bytes.)
```
@qq
```
After the substitution, call the macro recursively. Stop recording...
```
@q
```
... and call the macro. This recursive macro will run until no more substitutions can be made.
```
:%s/ //g<cr>
```
Replace all spaces on all lines with empty string.
[Answer]
# Scala 2.12, 71 bytes
Fixed a mistake thanks to @ophact
```
1.to(2)./:(_){_.transpose.map{r=>val(x,s)=r.partition(32<);x++s}->_ _1}
```
[Try it in Scastie!](https://scastie.scala-lang.org/pVSdd4b0TbuWsQlDFajO2w)
Takes a matrix of characters as input. The non-space characters have to be greater than 32 (ASCII).
```
1.to(2)  //Make the range[1..2]. This is just to repeat the function twice
./:(_){  //Fold over it with the input as the initial value for the accumulator
_.transpose  //Transpose the matrix first so we can work on the columns
 .map{r=>    //For every row,
  val(x,s)=r.partition(32<); //x is non-space characters, s is spaces
  x++s       //Join those together, with all the spaces at the end
 }->_   //Make a 2-tuple with the current number (either 1 or 2)
 _1}    //Get the first element of that tuple (the matrix), discarding the number
```
[Answer]
# [Pip](https://github.com/dloscutoff/pip) `-rl`, ~~11~~ 9 bytes
```
ZD J*||Zg
```
Takes input as lines of stdin, padded to a full rectangle. [Try it online!](https://tio.run/##K8gs@P8/ykXBS6umJir9//9EhSSFZIUUBYVUrrQ0hfT0dIUMhUwuhawshexshZycnP@6RTkA "Pip – Try It Online")
### Explanation
```
           g is list of lines of stdin (-r flag)
       Zg  Zip g (transposing into a list of lists of characters)
     ||    Strip whitespace from each character (replacing spaces with empty string)
   J*      Join each sublist into a single string
ZD         Zip again, padding shorter sublists with nil
           Autoprint with each sublist on a separate line (-l flag)
```
Changing the flags to `-rP` shows the actual structure of the list that gets output (`()` is nil):
```
["a";"f";"b";"g";"c";"g";"d";"h";"l";"e"]
["f";"j";"j";();"g";"k";();"l";();"i"]
[();();();();"k";();();();();"l"]
```
Since the `-l` flag joins each sublist together without a separator, and since nil normally produces no output, `-rl` gives us exactly the output we want:
```
afbgcgdhle
fjjgkli
kl
```
[Answer]
# JavaScript (ES10), 82 bytes
Expects a space-padded matrix of characters. Returns a list of lists of characters.
```
m=>m.map(r=>r.flatMap((_,x)=>m.some((r,y)=>1/(c=r[x])||m[y+=[,x]]?0:m[y]=1)?c:[]))
```
[Try it online!](https://tio.run/##RY9Pb8IwDMXv@RRWL9gay@AKCpy2204cSzWFkJSU/GFJN4HGPnuXdpN2en5@P1t2Jz9lVsle@scQj3owYvBi47mXF0xik7hxsn8tBt/mVxqTHL1GTPNbccsnVCLV14bud1/fHkQ9vzbNdrEqphFL2qpV3RANSb9/2KRxZvKMeNLy@GKd3t2CwgXxPu76ZEOLxPPF2R6rfdiHiriJ6VmqE2YQG/hiAB4E5H@oIOOdU1xzznND60IlXTpg0E9OxZCj09zFFkvy@9k4kXgXbcCqIvqrxo3wAJOu2TcNEg6g4AigmTHQti2cwDLoOjifwTnH2EQUOShWMFagHw "JavaScript (Node.js) – Try It Online")
[Answer]
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), 46 bytes
```
+`(?<=(.)*) (.*¶(?<-1>.)*(?(1)$))(\S)
$3$2 
 
```
[Try it online!](https://tio.run/##Dce5DYAwEATA/KrYwMGdEUhAylMEKQG/8SMCRG0UQGPGk829P/aaY8wm7puWC9ECLvT3puZll849l6JEeByEVK0qECjGGQtWbMBOxwFjDE5YgnPwHiGEHw "Retina 0.8.2 – Try It Online") Takes space-padded input. Note: Lines 2 and 3 end in a space. Explanation:
```
(?<=(.)*) (.*¶(?<-1>.)*(?(1)$))(\S)
$3$2 
```
Find a space above non-whitespace and exchange the two.
```
+`
```
Repeat until no more exchanges can be made.
```
 
```
Delete the remaining spaces.
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 26 bytes
```
ＷＳ⊞υιＦ²≔Ｅ§υ⁰◨Φ⭆υ§μλ›μ Ｌυυυ
```
[Try it online!](https://tio.run/##Nc1BCsIwFATQfU4xuPqBCuK2q26UgkLRE8Q2TdLGtKSJevuYIC7n8@ZPr4XvF2FTemtjJah1awz34I1TxDm6uGmKFQyv2bh40JGj2TajHF3FSk1o3SA/RRx4hU4MN6N0oJOxQXr6/Skwg799VrA847OXoqCcd9iVy0U6FfIcLyHmxS7XQ851SgIP9BgAycYRSiloGIZpwjzDWsvS/mW/ "Charcoal – Try It Online") Link is to verbose version of code. Takes input as newline-terminated space-padded list of strings. Explanation:
```
ＷＳ⊞υι
```
Input the strings.
```
Ｆ²
```
Repeat twice.
```
≔Ｅ§υ⁰◨Φ⭆υ§μλ›μ Ｌυυ
```
Transpose the array, filter out the spaces, then right-pad back to the original length.
```
υ
```
Output the final result.
[Answer]
# JavaScript (ES10[note](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#sort_stability)), 76 bytes
```
a=>(g=a=>a[0].map((c,i)=>a.map(l=>l[i]).sort((x,y)=>(y>' ')-(x>' '))))(g(a))
```
[Try it online!](https://tio.run/##TY7PbsMgDMbvPIVvGK1Fu0fktqdII5WmgZIQggiqiKY9e@aklTYf/PnPz/I36KdeuuRiPi/R3fs0zWHs182oTasaraKsm89WTjoidicnqD8ar2rfuFbIZU4ZsZxWWuFac@DijOVQCrSohdgquDINN@jgDtAzY8BaCw9wDIYBxhG89@xFkNw6RhgjiF1lTm5CehO9y8gv4RK4kGZOX7p7YAZVwzcDiMmFjAbzH0jYbrTsSCOlLK34NylymF1ATi7f1X7xceSK/Yhq@wU "JavaScript (SpiderMonkey) – Try It Online")
Just noticed that [this Python answer](https://codegolf.stackexchange.com/a/226795) by [hyper-neutrino](https://codegolf.stackexchange.com/users/68942/hyper-neutrino) used the same algorithm. You may upvote that one.
[Answer]
# [Husk](https://github.com/barbuz/Husk), 5 bytes
```
TmfIT
```
[Try it online!](https://tio.run/##yygtzv7/qKnx0Lb/IblpniH///9PVEhSSFZIUVBI5UpLU0hPT1fIUMjkUsjKUsjOVsjJyQEA "Husk – Try It Online")
same as jelly
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 47 bytes
```
a=PadRight[#/." "->Nothing]/. 0->" "&;a@a@#&
```
[Try it online!](https://tio.run/##TYyxTsMwFEX3fsWVI0Ug0ZY9amWpohILqghbnOHFSWy3iV2F1wkxM/KpfEIwzsJ23r33nZHYdiOx0zT32OFupt2J2ldnLFfZz/fXdiMg1vuXwNZ5U283eFzvY5QXJElm@XxfrEx8fAslT3FRZQ949tcbH8M01siLVanJV6fYsTSyl0/ahuPNa3bBV6aWB0sTae6md7kYyuvg@E8jlBfRUMsPQWig0QKd8n0PYwwsnPI4n3G5YBgGEfdplSA2yidEuhPFCImoieVSNFr5Nllh/gVYgs9i/gU "Wolfram Language (Mathematica) – Try It Online") Pure function. Takes a space-padded matrix of characters and returns the squashed matrix. This function uses the relatively straightforward algorithm: transpose, remove spaces, pad with spaces, and repeat once more. The Unicode character is U+F3C7 for `\[Transpose]`. Note that without the space, the `ReplaceAll` expression would be parsed as `/ .0 -> " "`.
]