summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arrange_optics_along_x.m9
1 files changed, 7 insertions, 2 deletions
diff --git a/arrange_optics_along_x.m b/arrange_optics_along_x.m
index 62db960..817656a 100644
--- a/arrange_optics_along_x.m
+++ b/arrange_optics_along_x.m
@@ -6,9 +6,14 @@ function optics = arrange_optics_along_x(optics_unsorted)
x=zeros(1,N);
for i=1:N
x(i)=optics_unsorted{i}.x;
- end
+ end
- [xs,indx]=sort(x);
+ if issorted(x)
+ optics = optics_unsorted;
+ return
+ end
+
+ [xs,indx]=sort(x);
cntr=1;
for i=indx
optics{cntr}=optics_unsorted{i};