package main import ( "fmt" "sort" ) func main() { var H, W int fmt.Scan(&H, &W) G := make([]int, H*W) for i := range(G) { fmt.Scan(&G[i]) } sort.Ints(G) for i := 0; i < H ; i++ { for j := 0; j < W; j++ { if j > 0 { fmt.Print(" ") } fmt.Print(G[i*W+j]) } fmt.Println() } }