Conditional sorting of columns in a matrix

I have a matrix with ten columns, and I want to rearrange these columns with three conditions.

  1. Column 1+2n and 2+2n (0<=n=<4) always remain together and in the same order (1+2n before 2+2n). Now we can say that we have five sets of columns, each having two columns.

  2. The 2+2n th columns should be sorted with respect to the first elements in them.

  3. In case first elements of any two 2+2n columns are same, they should be arranged with respect to the first elements of the corresponding 1+2n columns.

For example if the simplified matrix has only one row {1, 4, 7, 5, 8, 5, 0, 2, 3, 9}, it should be rearranged to {0, 2, 1, 4, 7, 5, 8, 5, 3, 9}.

Thanks for the help!