[Question]
  [
## Description
Your task is to output a 'depthmap' - that is, a heightmap of an object but not seen from its top but from its front.
For example, consider the following object as shown on the image. The height map is shown on the left. The corresponding depth map would be (as seen from standing at the arrow):
```
010
211   <- Depthmap
322
```
If you stand at the arrow, there are 3 cubes behind each other at the bottom left-hand point, 2 behind each other on the middle left-hand point, 0 at the top left-hand point etc.
![example](https://i.stack.imgur.com/xFc72.png)
## Input
Input is a two dimensional array of any sizes (not necessarily square).
## Output
Output is another two dimensional array which represents the depthmap. As you can deduce, its sizes are `(height x width)`. In the image, it would be `(3 x 3)`. Note that if the highest tower of cubes was 5, the depthmap would be an array of `(5 x 3)`.
## Winning condition
The shortest code wins.
## Disallowed
All languages allowed, no explicit restrictions. (I don't know what you can come up with, but play fair please.)
## Examples
```
Input:     Ouput:
5321       0001
1456       1012
2105       1112
           1212
           2222
           3323
Input:     Output:
22         01
13         12
00         22
Input:     Output:    (of the sample image)
232        010
210        211
101        322
```
  
[Answer]
### Golfscript, 42 chars
```
n%{n*~]}%zip:|[]*$),{:);n|{{)>},,}%}%-1%\;
```
results
```
$ golfscript 2657.gs < 2657-1.txt 
0001
1012
1112
1212
2222
3323
$ golfscript 2657.gs < 2657-2.txt 
01
12
22
$ golfscript 2657.gs < 2657-3.txt 
010
211
322
```
[Answer]
## Ruby 1.9, 102 characters
```
f=$<.map{|g|[*g.chop.bytes]}
f.flatten.max.downto(49){|j|puts f.transpose.map{|n|n.count{|r|r>=j}}*""}
```
Passes all testcases.
[Answer]
## Windows PowerShell, 108 ~~111~~ ~~114~~
```
(($i=@($input))-split''|sort)[-1]..1|%{$h=$_
-join(1..$i[0].Length|%{$x=$_-1
@($i|?{"$h"-le$_[$x]}).count})}
```
Passes all test cases.
[Answer]
## Haskell, 118 characters
```
import List
p h=map(\c->transpose(lines h)>>=show.length.filter(>=c))['1'..maximum h]
main=interact$unlines.reverse.p
```
---
* Edit (122 → 118): avoid filtering by only iterating to maximal height
[Answer]
## Scala 236 characters
```
object D extends App{var(l,m,z)=(io.Source.stdin.getLines.toList,0,0);val a=Array.ofDim[Int](l.head.size,10);for(i<-l;(j,q)<-i.zipWithIndex;x<-1 to j-48){a(q)(x-1)+=1;m=List(m,j-48).max};for(i<-1 to m){for(j<-a){print(j(m-i))};println}}
```
With some formatting:
```
object Depthmap extends App
{
    var(l,m,z)=(io.Source.stdin.getLines.toList,0,0)
    val a=Array.ofDim[Int](l.head.size,10)
    for(i<-l;(j,q)<-i.zipWithIndex;x<-1 to j-48)
    {
        a(q)(x-1)+=1
        m=List(m,j-48).max
    }
    for(i<-1 to m)
    {
        for(j<-a)
        {
            print(j(m-i))
        }
        println
    }
}
```
I'm sure a better facility with for comprehensions would mean I could cut some characters from this.
[Answer]
## JavaScript, ~~235~~ ~~208~~ 195 bytes
```
function _(b){for(e=Math.max.apply(0,b.join().split(",")),f=[],c=i=0;i<e;i++){for(
c=[],a=0;a<b[0].length;a++)for(d=c[a]=0;d<b.length;d++)b[d][a]>i&&c[a]++;f[e-i-1]
=c.join("")}return f.join("\n")}
```
Just for the record, this is the code I made up before posting the question. (Smallened now)
[Answer]
Haskell Version (Now optimized)
```
import Data.List
import Text.Parsec
import Text.Parsec.String
main= readFile"in.txt">>=(\t->either print(putStrLn.intercalate"\n".map(concatMap show).(\j->map (\n->(map(length.(filter(>=n)))(transpose$reverse j))) (reverse [1..(maximum$map maximum j)])))(parse(many1$many1 digit>>=(\x->newline>>(return$map(read.return)x)))""t))
```
Ungolfed version
```
import Data.List (foldl', transpose, intercalate)
import Text.Parsec
import Text.Parsec.String
-- Source:  http://codegolf.stackexchange.com/questions/2657/swapping-heightmaps-to-depthmaps
digitArray :: Parser [[Int]]
digitArray = many1 $ do xs <- many1 digit
                        optional newline
                        return $ map (read . return) xs
maxHeight :: Ord c => [[c]] -> c
maxHeight = maximum . (map maximum)
heightToDepth :: [[Int]] -> [[Int]]
heightToDepth ins = level (maxHeight ins)
        where level 0 = []
              level n = (map (length . (filter (>=n))) xs) : level (n-1)
              xs      = transpose $ reverse ins
lookNice xs = intercalate ['\n'] $ map (concatMap show) xs
main = do inText <- readFile "in.txt"
          case parse digitArray "" inText of
              Left err -> print err
              Right xs -> putStrLn $ lookNice $ heightToDepth xs
```
[Answer]
## Python, 117 chars
```
import sys
a=zip(*sys.stdin)[:-1]
n=int(max(map(max,a)))
while n:print''.join(`sum(e>=`n`for e in r)`for r in a);n-=1
```
Similar to Ventero's Ruby solution.
[Answer]
# [Uiua](https://www.uiua.org), 10 bytes
```
⇌⍉/+⬚0∵↯∶1
```
[Try it online!](https://www.uiua.org/pad?src=ZiDihpAg4oeM4o2JLyvirJow4oi14oav4oi2MQoKZiBbWzEgNF1bMiAyXVswIDBdXQpmIFtbNSAzIDIgMV1bMSA0IDUgNl1bMiAxIDAgNV1d)
```
⇌⍉/+⬚0∵↯∶1    input: a matrix of numbers
        ∵↯∶1    replace each number with that many 1s repeated...
     ⬚0         ...filling the remaining space in the 3D array with zeros
   /+            sum layers element-wise
⇌⍉              transpose and reverse to put the result in correct orientation
```
[Answer]
# [APL (Dyalog Extended)](https://github.com/abrudz/dyalog-apl-extended), 14 bytes
```
{⊖⍉+⌿⍵≥⍀⍳⌈/,⍵}
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNrShJzUtJTfn/v/pR17RHvZ3aj3r2P@rd@qhz6aPehke9mx/1dOjrAAVq/6c9apvwqLfvUd9UT/9HXc2H1hs/apsI5AUHOQPJEA/P4P@VQCXGCiaPereYKhgrGCkYAqGJgqmCGZhtoGDKxVXJ9ah3DVeaQiUA "APL (Dyalog Extended) – Try It Online")
```
{⊖⍉+⌿⍵≥⍀⍳⌈/,⍵}    Monadic function:
             ⍵     Start with a 2D array ⍵.
          ⌈/,      Find the overall maximum value h.
         ⍳         Make the list 1...h
       ≥⍀          Make a ≥ table between that list and ⍵.
                   Now we have a 3D matrix where position [a,b,c]
                   represents whether ⍵[a,b] is at least c.
    +⌿             We sum along the outermost (first) dimension, 
                   since that corresponds to a column of ⍵.
                   Now we have a 2D matrix where position [b,c]
                   represents how many values in column b of ⍵ are at least c.
  ⍉                Transpose so the heights are rows.
 ⊖                 Flip vertically.
```
[Answer]
## Clojure, 102 bytes
```
#(for[h(range(apply max(flatten %))0 -1)](map(fn[w _](count(for[r % :when(>=(r w)h)]_)))(range)(% 0)))
```
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 12 bytes
```
c rÔÆÕËè>X
w
```
[Try all test cases](https://ethproductions.github.io/japt/?v=1.4.6&code=YyBy1MbVy+g+WAp3&input=W1tbNSAzIDIgMV0KWzEgNCA1IDZdClsyIDEgMCA1XV0sCgpbWzIgMl0KWzEgM10KWzAgMF1dLAoKW1syIDMgMl0KWzIgMSAwXQpbMSAwIDFdXV0KLVFt)
Outputting the rows in reversed order would save [2 bytes](https://ethproductions.github.io/japt/?v=1.4.6&code=YyBy1MbVy+g+WA==&input=W1s1IDMgMiAxXQpbMSA0IDUgNl0KWzIgMSAwIDVdXQotUQ==), taking input in column-major order would save [1 byte](https://ethproductions.github.io/japt/?v=1.4.6&code=YyBy1MbL6D5YCnc=&input=W1s1IDEgMl0KWzMgNCAxXQpbMiA1IDBdClsxIDYgNV1dCi1R), doing both would (naturally) save [3 bytes](https://ethproductions.github.io/japt/?v=1.4.6&code=YyBy1MbL6D5Y&input=W1s1IDEgMl0KWzMgNCAxXQpbMiA1IDBdClsxIDYgNV1dCi1R)
Explanation:
```
c rÔ          #Find the maximum height
    Æ         #For each number X in the range [0...max_height]:
     Õ        # Get the columns of the input
      Ë       # For each column:
       è>X    #  Count how many items are greater than X
w             #Reverse the output
```
[Answer]
# [Julia](https://julialang.org), 55 bytes
```
!a=[sum(a[:,j].>m-i) for i=1:(m=max(a...)),j=axes(a,2)]
```
[Attempt This Online!](https://ato.pxeger.com/run?1=VVG7boMwFFVXvuKSyZYIwqa0FZGztAxd2g6JVMliMApIRkBRAImO_Y4uWfJR7dfUNg6htmzfxznn-trf53KopDidzkNfrB9-7l3BeDfUSPDYK1N_W68lhuLjCJKRGNWsFiMSvu9j7JVMjHmHhEdxOtF_b776vOs7YMAdHkEIFAhs1LqFCO6Upf0AohTYFngAek4AfVJjkdmi1qJ2bpSglgxTh1OLCdWuVC6CxBINycBC6-kSttAVHNgUMdqGkjq6W9UV5GOLQTZgWnJAjfYomx6tnl9iWGETOciurcQnEngJeN3vZkSmHsMV_8DZlJGFLgEug8z4C4Hk_S153CVPs8qSru9lgnlzuFatGoQdFZl-4vKhfw)
]