I found a solution that worked after some trial and error! I sorted the 2d array based on the y-values first. Then I pulled out a subset of the array. this subset isolated one row of spots at a time. I then sorted this subset based on their x positions, and stored it back in the sorted_ref_centroids array. I iterated through every row and it worked great!
% Sort the entire coordinate array based on y-values
X=ref_Centroids(:,1);
Y=ref_Centroids(:,2);
[sortedY, sortIndex] = sort(Y);
sortedX = X(sortIndex);
sorted_ref_Centroids(:,1)=sortedX;
sorted_ref_Centroids(:,2)=sortedY;
for i=0:N_r-1 %N_r is the number of rows of spots
% Now sort portions of the array. (y-values between 1-102,102-204, etc)
idx =i*N_c+1:(i+1)*N_c;%N_c is the number of columns of spots
%extract only part of the ref_centroids to sort
X=sorted_ref_Centroids(idx(1):idx(end),1);
Y=sorted_ref_Centroids(idx(1):idx(end),2);
%now sort this subset based on x-values.
[sortedX, sortIndex] = sort(X);
sortedY = Y(sortIndex);
%put this reordered subset back into ref_centroids
sorted_ref_Centroids(idx(1):idx(end),1)=sortedX;
sorted_ref_Centroids(idx(1):idx(end),2)=sortedY;
end