From b55f4d388314a2f6ac08f592677a721fb85c0d7e Mon Sep 17 00:00:00 2001
From: Mark Jenkinson <mark@fmrib.ox.ac.uk>
Date: Fri, 19 Nov 2004 16:36:03 +0000
Subject: [PATCH] Fixed bug in sort

---
 groupttest.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/groupttest.cc b/groupttest.cc
index ddb69e1..1f098e1 100644
--- a/groupttest.cc
+++ b/groupttest.cc
@@ -214,6 +214,7 @@ double pvalue(double tX, double dof) {
 } 
 
 
+
 vector<int> get_sortindex(const Matrix& vals)
 {
   // return the mapping of old indices to new indices in the
@@ -226,12 +227,11 @@ vector<int> get_sortindex(const Matrix& vals)
   sort(sortlist.begin(),sortlist.end());  // O(N.log(N))
   vector<int> idx(length);
   for (int n=0; n<length; n++) {
-    idx[n] = sortlist[n].second;
+    idx[sortlist[n].second-1] = n+1;
   }
   return idx;
 }
 
-
 ////////////////////////////////////////////////////////////////////////////
 
 // Main function - this does all the work
-- 
GitLab