Sorting Array Using Functions In Matlab