How would you print a matrix in spiral order?
Implement spiral_order(matrix) to return the elements of a rectangular matrix in clockwise spiral order, starting at the top-left corner. The input is a list of row lists, and the output must be a flat list. Handle single-row, single-column, rectangular, and empty matrices without revisiting elements.
def spiral_order(matrix):