Engineering A Sort Function Matlab