Skip to main content
Commonmark migration
Source Link

##Python, 43 bytes

Python, 43 bytes

lambda M:eval("map(sorted,zip(*"*2+"M))))")

The interesting question is how to apply mapsort-transpose twice. The shortest I found was to eval a string that has it twice. Compare some alternatives:

lambda M:eval("map(sorted,zip(*"*2+"M))))")
lambda M:map(sorted,zip(*map(sorted,zip(*M))))
s="map(sorted,zip(*%s))";lambda M:eval(s%s%M)
g=lambda M:map(sorted,zip(*M));lambda M:g(g(M))
f=lambda M,n=-1:n*M or f(map(sorted,zip(*M)),n+1)
def f(M):exec"M=map(sorted,zip(*M));"*2;return M

(The second and fourth can be shortened by 1 byte by aliasing sorted, but it's not enough.)

An alternative approach of converting to 1D, sorting, and reshaping to 2D, is very close, at 44 bytes. The width w is taken as an input.

lambda M,w:zip(*[iter(sorted(sum(M,[])))]*w)

##Python, 43 bytes

lambda M:eval("map(sorted,zip(*"*2+"M))))")

The interesting question is how to apply mapsort-transpose twice. The shortest I found was to eval a string that has it twice. Compare some alternatives:

lambda M:eval("map(sorted,zip(*"*2+"M))))")
lambda M:map(sorted,zip(*map(sorted,zip(*M))))
s="map(sorted,zip(*%s))";lambda M:eval(s%s%M)
g=lambda M:map(sorted,zip(*M));lambda M:g(g(M))
f=lambda M,n=-1:n*M or f(map(sorted,zip(*M)),n+1)
def f(M):exec"M=map(sorted,zip(*M));"*2;return M

(The second and fourth can be shortened by 1 byte by aliasing sorted, but it's not enough.)

An alternative approach of converting to 1D, sorting, and reshaping to 2D, is very close, at 44 bytes. The width w is taken as an input.

lambda M,w:zip(*[iter(sorted(sum(M,[])))]*w)

Python, 43 bytes

lambda M:eval("map(sorted,zip(*"*2+"M))))")

The interesting question is how to apply mapsort-transpose twice. The shortest I found was to eval a string that has it twice. Compare some alternatives:

lambda M:eval("map(sorted,zip(*"*2+"M))))")
lambda M:map(sorted,zip(*map(sorted,zip(*M))))
s="map(sorted,zip(*%s))";lambda M:eval(s%s%M)
g=lambda M:map(sorted,zip(*M));lambda M:g(g(M))
f=lambda M,n=-1:n*M or f(map(sorted,zip(*M)),n+1)
def f(M):exec"M=map(sorted,zip(*M));"*2;return M

(The second and fourth can be shortened by 1 byte by aliasing sorted, but it's not enough.)

An alternative approach of converting to 1D, sorting, and reshaping to 2D, is very close, at 44 bytes. The width w is taken as an input.

lambda M,w:zip(*[iter(sorted(sum(M,[])))]*w)
added 70 characters in body
Source Link
xnor
  • 146.6k
  • 26
  • 279
  • 652

##Python, 43 bytes

lambda M:eval("map(sorted,zip(*"*2+"M))))")

The interesting question is how to apply mapsort-transpose twice. The shortest I found was to eval a string that has it twice. Compare some alternatives:

lambda M:eval("map(sorted,zip(*"*2+"M))))")
lambda M:map(sorted,zip(*map(sorted,zip(*M))))
s="map(sorted,zip(*%s))";lambda M:eval(s%s%M)
g=lambda M:map(sorted,zip(*M));lambda M:g(g(M))
f=lambda M,n=-1:n*M or f(map(sorted,zip(*M)),n+1)
def f(M):exec"M=map(sorted,zip(*M));"*2;return M

(The second and fourth can be shortened by 1 byte by aliasing sorted, but it's not enough.)

Also compare toAn alternative approach of converting to 1D, sorting, and reshaping to 2D, is very close, at 44 bytes. The width w is taken as an input.

lambda M,w:zip(*[iter(sorted(sum(M,[])))]*len(M[0])]*w)

##Python, 43 bytes

lambda M:eval("map(sorted,zip(*"*2+"M))))")

The interesting question is how to apply mapsort-transpose twice. The shortest I found was to eval a string that has it twice. Compare some alternatives:

lambda M:eval("map(sorted,zip(*"*2+"M))))")
lambda M:map(sorted,zip(*map(sorted,zip(*M))))
s="map(sorted,zip(*%s))";lambda M:eval(s%s%M)
g=lambda M:map(sorted,zip(*M));lambda M:g(g(M))
f=lambda M,n=-1:n*M or f(map(sorted,zip(*M)),n+1)
def f(M):exec"M=map(sorted,zip(*M));"*2;return M

(The second and fourth can be shortened by 1 byte by aliasing sorted, but it's not enough.)

Also compare to converting to 1D, sorting, and reshaping to 2D

lambda M:zip(*[iter(sorted(sum(M,[])))]*len(M[0]))

##Python, 43 bytes

lambda M:eval("map(sorted,zip(*"*2+"M))))")

The interesting question is how to apply mapsort-transpose twice. The shortest I found was to eval a string that has it twice. Compare some alternatives:

lambda M:eval("map(sorted,zip(*"*2+"M))))")
lambda M:map(sorted,zip(*map(sorted,zip(*M))))
s="map(sorted,zip(*%s))";lambda M:eval(s%s%M)
g=lambda M:map(sorted,zip(*M));lambda M:g(g(M))
f=lambda M,n=-1:n*M or f(map(sorted,zip(*M)),n+1)
def f(M):exec"M=map(sorted,zip(*M));"*2;return M

(The second and fourth can be shortened by 1 byte by aliasing sorted, but it's not enough.)

An alternative approach of converting to 1D, sorting, and reshaping to 2D, is very close, at 44 bytes. The width w is taken as an input.

lambda M,w:zip(*[iter(sorted(sum(M,[])))]*w)
added 123 characters in body
Source Link
xnor
  • 146.6k
  • 26
  • 279
  • 652

##Python, 43 bytes

lambda M:eval("map(sorted,zip(*"*2+"M))))")

The interesting question is how to apply transpose-mapsort-transpose twice. The shortest I found was to eval a string that has it twice. Compare some alternatives:

lambda M:eval("map(sorted,zip(*"*2+"M))))")
lambda M:map(sorted,zip(*map(sorted,zip(*M))))
s="map(sorted,zip(*%s))";lambda M:eval(s%s%M)
g=lambda M:map(sorted,zip(*M));lambda M:g(g(M))
f=lambda M,n=-1:n*M or f(map(sorted,zip(*M)),n+1)
def f(M):exec"M=map(sorted,zip(*M));"*2;return M

(The second and thirdfourth can be shortened by 1 byte by aliasing sorted, but it's not enough.)

Also compare to converting to 1D, sorting, and reshaping to 2D

lambda M:zip(*[iter(sorted(sum(M,[])))]*len(M[0]))

##Python, 43 bytes

lambda M:eval("map(sorted,zip(*"*2+"M))))")

The interesting question is how to apply transpose-mapsort twice. The shortest I found was to eval a string that has it twice. Compare some alternatives:

lambda M:eval("map(sorted,zip(*"*2+"M))))")
lambda M:map(sorted,zip(*map(sorted,zip(*M))))
s="map(sorted,zip(*%s))";lambda M:eval(s%s%M)
g=lambda M:map(sorted,zip(*M));lambda M:g(g(M))
f=lambda M,n=-1:n*M or f(map(sorted,zip(*M)),n+1)
def f(M):exec"M=map(sorted,zip(*M));"*2;return M

(The second and third can be shortened by 1 byte by aliasing sorted, but it's not enough.)

##Python, 43 bytes

lambda M:eval("map(sorted,zip(*"*2+"M))))")

The interesting question is how to apply mapsort-transpose twice. The shortest I found was to eval a string that has it twice. Compare some alternatives:

lambda M:eval("map(sorted,zip(*"*2+"M))))")
lambda M:map(sorted,zip(*map(sorted,zip(*M))))
s="map(sorted,zip(*%s))";lambda M:eval(s%s%M)
g=lambda M:map(sorted,zip(*M));lambda M:g(g(M))
f=lambda M,n=-1:n*M or f(map(sorted,zip(*M)),n+1)
def f(M):exec"M=map(sorted,zip(*M));"*2;return M

(The second and fourth can be shortened by 1 byte by aliasing sorted, but it's not enough.)

Also compare to converting to 1D, sorting, and reshaping to 2D

lambda M:zip(*[iter(sorted(sum(M,[])))]*len(M[0]))
Source Link
xnor
  • 146.6k
  • 26
  • 279
  • 652
Loading