Index: /branches/eam_branches/ohana.20190329/src/libohana/include/ohana_sort.h
===================================================================
--- /branches/eam_branches/ohana.20190329/src/libohana/include/ohana_sort.h	(revision 40927)
+++ /branches/eam_branches/ohana.20190329/src/libohana/include/ohana_sort.h	(revision 40928)
@@ -84,4 +84,5 @@
 
 void dsort_indexonly (double *X, off_t *S, off_t N);
+void dsort_int_indexonly (double *X, int *S, int N);
 
 #endif
Index: /branches/eam_branches/ohana.20190329/src/libohana/src/sorts.c
===================================================================
--- /branches/eam_branches/ohana.20190329/src/libohana/src/sorts.c	(revision 40927)
+++ /branches/eam_branches/ohana.20190329/src/libohana/src/sorts.c	(revision 40928)
@@ -211,3 +211,18 @@
 }
 
-
+/* sort the index of a vector (vector stays unsorted) */
+void dsort_int_indexonly (double *X, int *S, int N) {
+  
+# define SWAPFUNC(A,B){ int 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
+
+}
+
+
