The following silly example defines a regression problem with the constraint that the sum of the largest value and the smallest value of the decision variable is 1. As usual, we add explicit bound constraints to improve the big-M reformulations.
b = randn(20,1)*20;
x = sdpvar(5,1);
e = b-A*x;
[s,location] = sort(x);
F = [s(1)+s(end) == 1, -100 <= x <= 100];
Note that we can solve this particular problem more efficiently by using max and min instead (still a nonconvex problem, but it leads to a model with 10 binary variables, compared to the sort model which leads to 25 binary variables.)
The integer model for the sort operator is extremely expensive. Sorting a variable of n variables requires n2 binary variables.