Given a matrix x with n rows and m columns, return a matrix y with n rows and 2m columns, such that every row in x is sorted from low to high and then from high to low.

Example:

x = 9  2  8  1
    5  4  9  8
    8  9  6  9
y = 1  2  8  9  9  8  2  1
    4  5  8  9  9  8  5  4
    6  8  9  9  9  9  8  6

Solution Stats

1062 Solutions

331 Solvers

Last Solution submitted on Mar 29, 2026

Last 200 Solutions

Problem Comments

Solution Comments

Show comments
Loading...

Problem Recent Solvers331

Suggested Problems

More from this Author25

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!