Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

added 515 characters in body
Source Link
Jonah
  • 34.1k
  • 4
  • 41
  • 95

J, 19 bytes

(]/:~"1/:)"_ 1],:/:

Try it online!

  • Main verb ]/:~"1/:
    • The right most /: sorts the left arg (matrix) according to the order that would sort the right arg (specified order). This sorts rows.
    • Now that result get sorted /:~"1 again according to the order specified ]. But this time we're sorting with rank 1, ie, we're sorting each row, which has the effect of sorting columns.
  • ],:/: We apply the above using both the order specified ] and the grade up of the order specified /:. This gives us the 2 results we want.

J, 19 bytes

(]/:~"1/:)"_ 1],:/:

Try it online!

J, 19 bytes

(]/:~"1/:)"_ 1],:/:

Try it online!

  • Main verb ]/:~"1/:
    • The right most /: sorts the left arg (matrix) according to the order that would sort the right arg (specified order). This sorts rows.
    • Now that result get sorted /:~"1 again according to the order specified ]. But this time we're sorting with rank 1, ie, we're sorting each row, which has the effect of sorting columns.
  • ],:/: We apply the above using both the order specified ] and the grade up of the order specified /:. This gives us the 2 results we want.
Source Link
Jonah
  • 34.1k
  • 4
  • 41
  • 95

J, 19 bytes

(]/:~"1/:)"_ 1],:/:

Try it online!

AltStyle によって変換されたページ (->オリジナル) /