From f765fbee982c55713de7d54b79a61db479c462f8 Mon Sep 17 00:00:00 2001
From: Mark Jenkinson <mark@fmrib.ox.ac.uk>
Date: Tue, 20 Aug 2013 13:47:17 +0000
Subject: [PATCH] Changed get_sortindex function to use a strictly less than
 function based _only_ on the first element of the pair

---
 miscmaths.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/miscmaths.cc b/miscmaths.cc
index d33f586..a95d991 100644
--- a/miscmaths.cc
+++ b/miscmaths.cc
@@ -624,6 +624,7 @@ namespace MISCMATHS {
       return matnew;
     }
 
+  bool strict_less_than(pair<double, int> x, pair<double, int> y) { return x.first < y.first; }
 
   vector<int> get_sortindex(const Matrix& vals, const string& mode, int col)
   {
@@ -634,7 +635,7 @@ namespace MISCMATHS {
     for (int n=0; n<length; n++) {
       sortlist[n] = pair<double, int>((double) vals(n+1,col),n+1);
     }
-    sort(sortlist.begin(),sortlist.end());  // O(N.log(N))
+    sort(sortlist.begin(),sortlist.end(),strict_less_than);  // O(N.log(N))
     vector<int> idx(length);
     for (int n=0; n<length; n++) {
       if (mode=="old2new") {
-- 
GitLab