Function which sorts the input to have following property: x1 <= x2 >= x3 <= x4 >= ...