Both while and if are keywords rather than functions, so saying that those are permitted to be used does not alter what can be done without functions.
In short: in order to compare numbers to each other you have to do a computation (checking to see if they are equal, at the very least), and all computation involving two numbers in MATLAB involves using built-in functions, but you are not permitted to use built-in functions.
So you cannot compare x(1) to x(2) without using a comparison and that involves using a built-in function.
There are computer languages where comparisons and very simple indexing are both built-in operators, and with those languages it is technically possible to sort a fixed-length vector without using any built-in functions... but it might be very tedious. And those languages are not MATLAB.