[Question]
  [
This was inspired by [this question](https://codegolf.stackexchange.com/questions/235446/neural-processing-lattice-checker).
Given an \$m\times n\$ matrix of \$0\$'s and \$1\$'s, apply "gravity" to it. This means to drop down all the \$1\$'s as if they were affected by gravity.
For example
```
[[1,0,1,1,0,1,0]
 [0,0,0,1,0,0,0]
 [1,0,1,1,1,1,1]
 [0,1,1,0,1,1,0]
 [1,1,0,1,0,0,1]]
```
Should result in
```
[[0,0,0,0,0,0,0]
 [0,0,0,1,0,0,0]
 [1,0,1,1,0,1,0]
 [1,1,1,1,1,1,1]
 [1,1,1,1,1,1,1]]
```
As all \$1\$'s have been dropped down.
## input
Input will be atleast \$1\times 1\$. You may take input in all reasonable forms (Bitsets, arrays, Lists) and either output the result, return a new Bitset, array or list or simply modify the input.
This is code golf, so the answer with the fewest bytes wins!
## test-cases
More test-cases:
```
[[1,0]                   [[0,0]
 [0,0]            ->      [1,0]
 [1,0]]                   [1,0]]
[[1,1,1,1,1]            [[1,0,1,1,0]
 [1,0,1,1,0]      ->     [1,1,1,1,0]
 [1,1,1,1,0]]            [1,1,1,1,1]]
[[1]]             ->    [[1]]
```
The brackets are just there to visualize arrays, they are *not* required in your output!
  
[Answer]
# [Japt](https://github.com/ETHproductions/japt) v2.0a0, 2 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
Transposes, sorts each row and automatically transposes back.
```
yn
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=2.0a0&code=eW4&input=W1sxLDAsMSwxLDAsMSwwXQogWzAsMCwwLDEsMCwwLDBdCiBbMSwwLDEsMSwxLDEsMV0KIFswLDEsMSwwLDEsMSwwXQogWzEsMSwwLDEsMCwwLDFdXQotUg)
## [Japt](https://github.com/ETHproductions/japt), 3 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
Transpose, sort rows, transpose.
```
yÍy
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=ec15&input=W1sxLDAsMSwxLDAsMSwwXQogWzAsMCwwLDEsMCwwLDBdCiBbMSwwLDEsMSwxLDEsMV0KIFswLDEsMSwwLDEsMSwwXQogWzEsMSwwLDEsMCwwLDFdXQotUg)
[Answer]
# [Haskell](https://www.haskell.org/), 41 bytes
```
import Data.List
t=transpose
t.map sort.t
```
[Try it online!](https://tio.run/##Rcs9CsQgEAXg3lNMkXIQPYDdlskJJMUUkZWNRpy5v/kRszwYeMP3vsS/bd9bi6kcVeBDQnqOLEqcVMpcDt5UcKITFeCLaGmJYnZXX6DUmGUKCjx4iwYt9mtWBQjeoOn1Tn8N9WSoMbN/Zd/hrdZ2Ag "Haskell – Try It Online")
This is the same boring answer you've already seen in this thread. Unfortunately it's quite short. Here's a fun answer that doesn't import anything:
# No imports, ~~53~~ 49 bytes
```
q=foldr.zipWith
e=[]:e
q(:)e.q([(0:),(++[1])]!!)e
```
[Try it online!](https://tio.run/##RYtBCsMgFET3nsJAFko@QbeCR@i6i89fCFEiNammWfXyllRsGRiY4b3VvR4@pVqLDc@0HPM75ns8V@YtkvEs2CKM9HMRKJSRIKYJNUkaBunr5uJuN5dvPB9xP8fAOHLUoEBDa0WMA0cFqs0r7erUN53qmv5T@ideFNUP "Haskell – Try It Online")
This answer is a little odd.
# Explanation
Let's first solve an easier problem. Instead of having gravity acting down it will act to the right.
Here each row acts independently so we can just solve it on 1 row and map it across the whole thing. We start by making a function
```
0#x=0:x
1#x=x++[1]
```
This takes a list and a value, adds it to the front if it is `0` and the end if it's `1`. This will always insert new values to the proper place in the row, so to build the row we can just do:
```
foldr(#)[]
```
and to make the complete thing we just add the `map`
```
f=map$foldr(#)[]
```
---
Ok, now we want to solve the original problem. How can we make this act on the columns? The idea is to use `zipWith`. `zipWith` acts independently on the columns of two lists to combine them. So
`zipWith(#)` will take a list of columns and a list of values and add each value to the corresponding column. To do this repeatedly we use `foldr`
```
e=[]:e
foldr(zipWith(#))e
```
The issue however arises that because we are treating the columns as lists the output is transposed. So we need to transpose it back.
If we take a look at the short way to transpose in Haskell [here](https://codegolf.stackexchange.com/a/111362/56656)
```
e=[]:e
foldr(zipWith(:))e
```
we instantly notice that this is extremely similar to the code we have already written, so we can abstract it. When we do that and add in our transpose we get nearly the final answer
```
0#x=0:x
1#x=x++[1]
q=foldr.zipWith
e=[]:e
f=q(:)e.q(#)e
```
The last change is that we can express our original function `(#)` in pointfree as `([(0:),(++[1])]!!)` and substitute it where `(#)` goes.
```
q=foldr.zipWith
e=[]:e
f=q(:)e.q([(0:),(++[1])]!!)e
```
[Answer]
# [R](https://www.r-project.org/), 26 bytes
Or **[R](https://www.r-project.org/)>=4.1, 19 bytes** by replacing the word `function` with `\`.
```
function(m)apply(m,2,sort)
```
[Try it online!](https://tio.run/##K/qfZvs/rTQvuSQzP08jVzOxoCCnUiNXx0inOL@oRPN/mkZuYklRZoVGsoahjoGOoQ6ENNDhUjDQMYCyDcB8mDwEguRhqg2h8oZw9YaaOqY6OiGamlxoFkCN1NQxxiKNgMhmG2LXABTW1PwPAA "R – Try It Online")
[Answer]
# [C (clang)](http://clang.llvm.org/), ~~80 79 73~~ 64 bytes
```
i;f(*a,w,h){for(i=w;i<w*h;)i=a[i-w]>a[i]?a[i-w]---a[i]+++w:i+1;}
```
[Try it online!](https://tio.run/##pZHRCsIgFIbv9xQiBDoV2qKb3OpBwgtZrITaYhUuYs@@jtuKWtSizkF@f/38vTiJSLY6W9e1kSnxNbd8Qy9pXhATW2ki628kNbFeGmHVHEQt2r0QwjnGmJ0ZFsiqNtkR7bTJCEUXD0G5A71UKO68qzH/3MFAvw3qg0P3L0H9h9/6p6Ab8Is@BAX8j9XkVLKRlGg@CfmUdjYvEHFjOcNQxhIkQlMQxujDjO5U2VIlUJMQFLA75GpfAJUSPFohzGHUJWIQ6QOsug8b6nQ8EIy7k8qr6is)
This is essentially a strided sort looped over all columns except instead of swapping out of order elements, ~~both elements are xor'ed by one~~ out of order elements are decremented and incremented until they are in order. Thanks to @jdt for the -9!
Slightly less golfed
```
x,*u;
f(*a,w,h){
  for(x=w*h*--h;x--;)
    w[u=a+x%h*w-x/h/~h]<*u?
      u[w]^=1,
      *u^=1
    :
      0;
}
```
[Answer]
# [APL (Dyalog Extended)](https://github.com/abrudz/dyalog-apl-extended), 5 [bytes](https://github.com/abrudz/SBCS)
```
∧⍤1⍢⍉
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNrShJzUtJTfn//1HH8ke9Swwf9S561Nv5P@1R24RHvX2P@qZ6@j/qaj603vhR20QgLzjIGUiGeHgG/69QAKpRMFUwV3jUu0XBUMEAiCGkARQaItGGcGiAlQSr46rgUte1U@dKU6gAAA "APL (Dyalog Extended) – Try It Online")
Sort `∧` each row `⍤1` while transposed `⍢⍉`
---
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 9 [bytes](https://github.com/abrudz/SBCS)
```
⊖⍳∘≢∘.≤+⌿
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT////1HXtEe9mx91zHjUuQhI6j3qXKL9qGf//7RHbRMe9fY96pvq6f@oq/nQeuNHbROBvOAgZyAZ4uEZ/L9CAahGwVTBXOFR7xYFQwUDIIaQBlBoiEQbwqEBVhKsjquCS/1R2yR1rjSFCgA "APL (Dyalog Unicode) – Try It Online")
`+⌿` sum of each column  
`⍳∘≢` indices from 1 to the number of rows  
`∘.≤` `≤`-table between these two vectors  
`⊖` vertically reverse the resulting matrix
[Answer]
# [Python 3](https://docs.python.org/3/), 34 bytes
```
lambda a:zip(*map(sorted,zip(*a)))
```
[Try it online!](https://tio.run/##PY3BCsMgEETvfsUe3bAHl94C@RLrYUsiFRIV66X9eUNMEwYGZnjD5G99p/hofnq2VbbXLCDjL2Q9bJL1J5W6zNSzIGLzqcAa4gIhgtfKWiZDTKcbRwqsIXOmQ725mK4/c234ZvhesXMKR8glxKqPN2w7 "Python 3 – Try It Online")
*-3 bytes thanks to pxeger*
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 6 bytes
```
ÞTvsÞT
```
[Try it Online!](https://lyxal.pythonanywhere.com?flags=&code=%C3%9ETvs%C3%9ET&inputs=%5B%5B1%2C0%2C1%2C1%2C0%2C1%2C0%5D%2C%5B0%2C0%2C0%2C1%2C0%2C0%2C0%5D%2C%5B1%2C0%2C1%2C1%2C1%2C1%2C1%5D%2C%5B0%2C1%2C1%2C0%2C1%2C1%2C0%5D%2C%5B1%2C1%2C0%2C1%2C0%2C0%2C1%5D%5D&header=&footer=)
There's probably something cleverer / shorter.
```
ÞT     # Transpose
  vs   # Sort each
    ÞT # Transpose
```
[Answer]
# MATLAB / [Octave](https://www.gnu.org/software/octave/), 13 bytes
```
@(M)sort(M,1)
```
[Try it online!](https://tio.run/##y08uSSxL/Z9mq6en999Bw1ezOL@oRMNXx1Dzf5pGtKGOgY6hDoQ0sOZSUFAw0DGA8EAQLAJTA4ZQNTA9hnA1hnBdhrGa/wE "Octave – Try It Online")
### How it works
Anonymous function that `sort`s along the `1`st dimension, i.e. vertically.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 4 bytes
```
ZṢ€Z
```
[Try it online!](https://tio.run/##y0rNyan8/z/q4c5Fj5rWRP0/uSDscPv/6GhDHQMdQx0IaRCrE22gYwBhgyCQD5MHQ7A8TLUhVN4Qrt4wNhYA "Jelly – Try It Online")
A monadic link which takes a 2d array of booleans.
```
Z    # Transpose
  €  # For each
 Ṣ   # Sort
   Z # Transpose back
```
[Answer]
# [Factor](https://factorcode.org/), 34 bytes
```
[ flip [ natural-sort ] map flip ]
```
[Try it online!](https://tio.run/##bZBNDsIgEIX3PcW7gKYkrvQAxo0b46rpAptpQ6SAQBe18ex1tPZHYyYw5M33HoFSFtH6/nw6HPdbBLo1ZAoKCNZHZSo4TzG2zisTcSVvSENZVGTIS63uMiprAnZJ0qGDQMpr2FM8ErCWvkt8@qCN3FAjJxb@kROTlzlWp2vm8DlyAXxn/8sVvxY@9hlKrRwyGBkbfuDq9Q3IUUs3THJGgqqdplWUF01rGM3zwtbOBsKGjc7ptn8C "Factor – Try It Online")
Transpose (flip), sort each row, transpose.
[Answer]
# [Python 3](https://docs.python.org/3/) + [NumPy](https://numpy.org/), 18 bytes
```
lambda a:a.sort(0)
```
[Try it online!](https://tio.run/##RYuxCsMwDER3fYVGG0SQ6VbIl6QZVEpooHaE4w7@eteuccuBdHe805yeR7iUbb6Vl/j7Q1CuMp1HTIZt2b1Wh@HtNaOcGBRAcK5/khglmwUQF0dMjvrllVrFxD029WpQXw1qzNyfcr9ho1YLsBmxoHEPqZryAQ "Python 3 – Try It Online")
Input a `np.array`, output by modify it in-place.
[Answer]
# JavaScript (ES6), 53 bytes
Suggested by [@l4m2](https://codegolf.stackexchange.com/users/76323/l4m2): counting the number of 1's on each column, using `.filter()`.
Returns a matrix of Boolean values.
```
m=>m.map((r,y)=>r.map((_,x)=>!m.filter(r=>!r[x])[y]))
```
[Try it online!](https://tio.run/##XY9RCsMgEET/c4rtn4IVPYAeoRcQKTbVkhJj2KQlOb21DbQ2sCwzDPuYvbunm1rsxvk4pKvPQeWodOTRjYQgW6nSuJkzW4o5RB66fvZIsBg0i6VmtZTmNg1T6j3v040EYhoAA5KBYO/9FQIsqyLBfmIXyXqqqKbtgPIfWK4aSz/lEZSG7Y/TI1480tL4BQ "JavaScript (Node.js) – Try It Online")
---
# JavaScript (ES6), 55 bytes
Sorting the columns.
```
m=>m.map((r,y)=>r.map((_,x)=>m.map(r=>r[x]).sort()[y]))
```
[Try it online!](https://tio.run/##VY5hCoMwDIX/e4r@bCAr7QHqRUoZxenYsEZSGXr6TjeVCo/wksf3yDt8Qmr4NU63gR5t7myOto4qhlFKxgVszf/ljjMcCa9XN3tQiXiS4BYPkBsaEvWt6ukpO@kqIZwwKDRu8zRaePxFGneZw5xRSe0qqLLNXClzLVypavvsCw "JavaScript (Node.js) – Try It Online")
---
# JavaScript (ES6), 57 bytes
Counting the number of 1's on each column, using `.some()`.
Returns a matrix of Boolean values.
```
m=>m.map((r,y)=>r.map((_,x)=>m.some(r=>!m[n+=r[x]],n=y)))
```
[Try it online!](https://tio.run/##VY9dCsIwEITfe4r1LcG1NAfYHMELhCC1pqI0SdmotKev9sfSwrDsMnzDzrP8lKniR/s6hXhzQ02DJ@1zX7ZCMPaSNM/HBTs5Oil6J5j0wZtwJDadtRiol1IOVQwpNi5v4l3UwmQABhRCgeNclwIsTlaBi9R/Wa0ttWhDbdPUnlL7wB@VWTkVYCANc5fz218djx9/AQ "JavaScript (Node.js) – Try It Online")
[Answer]
# [MY](https://bitbucket.org/zacharyjtaylor/my-language), 11 bytes
```
⎕⍉86ǵ'ƒ⇹(⍉←
```
[Try it online!](https://tio.run/##y638//9R39RHvZ0WZse3qh@b9Kh9pwaQ96htwv//0dGGOlAYqxNtAKQNQBDIhoiC2LEA "MY – Try It Online")
```
⎕⍉86ǵ'ƒ⇹(⍉←
⎕              - Input
 ⍉             - Transpose
   86ǵ'ƒ⇹(     - Sort each
           ⍉   - Transpose again
             ←  - Output
```
[Answer]
# [RAD](https://bitbucket.org/zacharyjtaylor/rad), 4 bytes
```
⍉<⍉⍵
```
[Try it online!](https://tio.run/##K0pM@f//UW@nDRA/6t36//9/DQ1DBSjUVNAwANIGIAhkQ0RBbE0A "RAD – Try It Online")
Transpose the input (`⍉⍵`), sort each (`<`), then retranspose `⍉`.
[Answer]
# [jq](https://stedolan.github.io/jq/), 28 bytes
```
[transpose[]|sort]|transpose
```
[Try it online!](https://tio.run/##yyr8/z@6pCgxr7ggvzg1OramOL@oJLYGLvK/JjexQMOhOEMzOvZ/dLShjoGOoQ6ENIjV4VKINtAxgPBAECwCUwOGUDUwPYZwNYZwXYaxsf/yC0oy8/OK/@sWAQA "jq – Try It Online")
[Answer]
# [C (clang)](http://clang.llvm.org/), 92 bytes
```
c,x,y,*p;f(*a,w,h){for(x=0;x<w;x++)for(c=y=0;y<h*2;y++)p=a+x+y%h*w,y<h?c+=*p:(*p=y-h>=h-c);}
```
[Try it online!](https://tio.run/##VY9va8MgEIff91NIoOCfC5hBCcy4fZDRF@KwFto0pB1RSr763JmkITvBH/fwcJ62tBfTnlKyECAC75Sj3MAAnj3dradBSxWaQQUhWO6tjkhi4/mbisg6bUQQce/5AEg/rdC8e6e807H0H9qXlqkxndsHuZpzSxl57ghWBubrSPTS56pAQgXzLWHFEuSC5Ba/7Pls7NeI6r9drUOqiY5qCkcN1HBgS3frCc27RdxMKoyGHDDwo5tFVyvMVkCrxkBrdXJ1PUqOFvtvUgB@NxCBEzmpj8tzk/TzuNOiWMi4G9OvdRdzuqdy@AM "C (clang) – Try It Online")
[Answer]
# [Ruby](https://www.ruby-lang.org/), 38 bytes
```
->l{l.transpose.map(&:sort).transpose}
```
[Try it online!](https://tio.run/##KypNqvyfZvtf1y6nOkevpCgxr7ggvzhVLzexQEPNqji/qEQTIVr7v0AhLTo62lDHQMdQB0IaxOpwKUQb6BhAeCAIFoGpAUOoGpgeQ7gaQ7guw9jY2P8A "Ruby – Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 4 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
ø€{ø
```
Similar as some of the other answers.
[Try it online](https://tio.run/##yy9OTMpM/f//8I5HTWuqD@/4/z862lDHQMdQB0IaxOpEG@gYQNggCOTD5MEQLA9TbQiVN4SrN4yNBQA) or [verify all test cases](https://tio.run/##yy9OTMpM/V@m5JlXUFpipaBkX2l7aLcOl5J/aQlM4P/hHY@a1lQf3vEfJHVom/3/6OhoQx0DHUMdCGkQqxNtoGMAYYMgkA@TB0OwPEy1IVTeEK7eMDZWRwFsJMQgiHaYIMIMdP0QNkRZbGwsAA).
**Explanation:**
```
ø     # Zip/transpose the (implicit) input-matrix, swapping rows/columns
 €{   # Sort each inner list
   ø  # Zip/transpose back
      # (after which the result is output implicitly)
```
[Answer]
# JavaScript, 142 Bytes
```
for(j=0,l=a.length,w=a[0].length,c=new Array(l),e=1;j<w;j++){for(i=0;i<l;i++){if(a[i][j]){p=l-e++;!c[p]&&(c[p]=new Array(w));c[p][j]=1}}e=1;}
```
Where `a` is the input array and `c` is the output array.
Might be cheating since I am pulling a vacuum on all the 0s rather then applying gravity to all the 1s.
It works similar to the rest of the solutions where you need to rotate the array and sort it but it does it all in one go and without using any of the built in sort/rotate functions.
[Answer]
# [Pari/GP](http://pari.math.u-bordeaux.fr/), 15 bytes
```
a->vecsort(a~)~
```
[Try it online!](https://tio.run/##K0gsytRNL/ifpmD7P1HXriw1uTi/qEQjsU6z7n9iQUFOpUaigq6dQkFRZh5QVEEJxFFSSNNI1NTUiY421DHQMdSBkAbWBjoGEBYIWsPkwNAaoc4QLGcIV2kYqxMN1Q3SA@bBdKHqALNA8rGxmv8B "Pari/GP – Try It Online")
[Answer]
# TI-Basic, 54 bytes
```
Input [A]
dim([A]
For(I,1,Ans(2
Matr►list([A],I,A
SortA(ʟA
For(J,1,dim(ʟA
ʟA(J→[A](J,I
End
End
```
Output is stored in `[A]`, which was the inputted matrix.
[Answer]
# [Swift 5.5/Xcode 13.0](https://developer.apple.com/swift/), 215 bytes
```
var c=[Int:Int]();let d=m.count;let e=m[0].count;for i in 0..<e{for j in 0..<d{c[i,default:0]+=m[j][i]}};var r=Array(repeating:Array(repeating:1,count:e),count:d);for k in c{for i in 0..<d-k.1{r[i][k.0]=0}};return r
```
[Try it online!](https://tio.run/##fZDdaoQwEIXvfYq5VJqVBHrlNgu9Kn2GkIsQY8m6RknHbUV8dmv82e5aaAbCnMNMvkM@v2yBz2PROg2qaS7dm1dXi12MNVQZCPHuUMoEDqeth368Kg@aB5kFK06OF4OQ8yrVdetwVoZXgsrVKGoPFqwDmqYvpg/yvMm818KS3BSqvWBG5dO0eJbCymE4BpDnr96rLvamMQqt@8j2mpGZkplkbfJkJpYBofsHeH4oU9b76XlRplRyOlG8wdY78OMQRSG6dU2LwPf/kYkIpiMYoYSR5aaSLCYldDFCbeY2Odfv5LbM7ifZbT1MymSJYr4bo9HkUxpxD6KPoH/pdA/6E2lvyihqvHUYrz/BbzmS8Qc "Swift – Try It Online")
[Answer]
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), 39 bytes
```
+`(?<=(.)*)1(.*¶(?<-1>.)*(?(1)^))0
0$+1
```
[Try it online!](https://tio.run/##K0otycxL/P9fO0HD3sZWQ09TS9NQQ0/r0DYgV9fQDsjXsNcw1IzT1DTgMlDRNvz/31DHQMdQB0ICxXQMICwQ5ILJgSEXQp0hWM4QrtIQAA "Retina 0.8.2 – Try It Online") Takes input as a list of digit strings although commas can be redundantly included as per the example link. Explanation: .NET's balancing groups are used to ensure that the regular expression matches a `1` directly above a `0`; the digits are thus exchanged. `$+` is used instead of `$2` due to the following digit which would otherwise be interpreted as part of the substitution name. The `+` modifier repeats the substitutions until all of the gravity has been applied.
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), ~~35~~ 20 bytes
```
ＷＳ⊞υι↑Ｅθ⭆²Φ⭆υ§νκ⁻Ｉνλ
```
[Try it online!](https://tio.run/##RYvLCgIxDEX3/YosU6iQunRWIgizEAbEDyhjscVSxz7Uv6/puPASAuckd3YmzQ8TWns7HyzgGJdaziX5eEMpYarZYVXg5SAmlgV3l0XBySz4VPD767BVcPSh2IR/x7V9GePVfjAquEvJPR9rxoPJBSNjkD1Da5o0Dwki3kSiM0esmv16JS3a5hW@ "Charcoal – Try It Online") Link is to verbose version of code. Takes input as a list of digit strings. Explanation:
```
ＷＳ⊞υι
```
Read the input.
```
↑Ｅθ⭆²Φ⭆υ§νκ⁻Ｉνλ
```
Map over each column, taking the transpose and filtering out the `0`s and `1`s each time, so that the `1`s are effectively sorted to the front, but then print the whole lot vertically which rotates the result so that the mapped rows turn back into columns but also the `1`s end up at the bottom as desired.
Previous 35-byte canvas-based version:
```
ＷＳ⟦ι⟧↑ＷＫＫ«ＷＫＫ«Ｆ⁼⪫ＫＤ²↓ω10↓01↑»↓ＷＫＫ↓↗
```
[Try it online!](https://tio.run/##ZY29CsIwFIXn5ClCpxQiJI7tWgcFoShO4lBKbIMhqTVtB@mzxzT9USmXhHPPdy4nL7M615m0tiuF5AjvVdWYs6mFKnAYotQJg6/iFsbwqFuOo0vl5BROOX8MqTcEawfcdY3w7tlk8oUPWigPE1Hz3Ait8JagKNGdCgnq3AsYDZZCD5xHWeDaAPipBj2cVn8cr6r/4Xx5EkVpnNFbywgljIw/hZTQUQ0DZ@YHfnPMM7YkGbSbVn4A "Charcoal – Try It Online") Link is to verbose version of code. Takes input as a list of digit strings although commas can be redundantly included as per the example link. Explanation:
```
ＷＳ⟦ι⟧
```
Copy the input to the canvas.
```
↑
```
Start at the bottom of the first column.
```
ＷＫＫ«
```
Repeat while there are still columns to process.
```
ＷＫＫ«
```
Repeat until this column has been processed.
```
Ｆ⁼⪫ＫＤ²↓ω10
```
If this column contains a `1` above a `0`, then...
```
↓01
```
... switch the characters, moving down so that the `1` gets considered for gravity again on the next pass.
```
↑
```
Try the next digit.
```
»↓ＷＫＫ↓↗
```
Locate the bottom of the next column.
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 4 bytes
```
CSMC
```
[Try it online!](https://tio.run/##K6gsyfj/3znY1/n//@hoQx0FAx0FQzCCMAxidRSiDcA8A5iwAVQYWTUUQVUjm2CIUG2IaohhbCwA "Pyth – Try It Online")
```
CSMC
   C  # transpose the matrix
 SM   # sort each row
C     # transpose again
```
]