Index: /branches/eam_branches/ohana.20190329/src/libohana/include/ohana_sort.h
===================================================================
--- /branches/eam_branches/ohana.20190329/src/libohana/include/ohana_sort.h	(revision 40750)
+++ /branches/eam_branches/ohana.20190329/src/libohana/include/ohana_sort.h	(revision 40751)
@@ -83,3 +83,5 @@
 void isortfour (int *X, int *Y, int *Z, int *W, int N);
 
+void dsort_indexonly (double *X, off_t *S, off_t N);
+
 #endif
Index: /branches/eam_branches/ohana.20190329/src/libohana/src/sorts.c
===================================================================
--- /branches/eam_branches/ohana.20190329/src/libohana/src/sorts.c	(revision 40750)
+++ /branches/eam_branches/ohana.20190329/src/libohana/src/sorts.c	(revision 40751)
@@ -196,2 +196,18 @@
 }
 
+/* sort the index of a vector (vector stays unsorted) */
+void dsort_indexonly (double *X, off_t *S, off_t N) {
+  
+# define SWAPFUNC(A,B){ off_t itmp; \
+  itmp = S[A]; S[A] = S[B]; S[B] = itmp; \
+}
+# define COMPARE(A,B)((!isfinite(X[S[A]]) && isfinite(X[S[B]])) || (X[S[A]] < X[S[B]]))
+
+  OHANA_SORT (N, COMPARE, SWAPFUNC);
+
+# undef SWAPFUNC
+# undef COMPARE
+
+}
+
+
