diff --git a/math/mathcore/inc/TMath.h b/math/mathcore/inc/TMath.h
index ce0365c4fcb8ea1c13549f52171bcb97fecace52..c8474b5f9201d8fe517eba11608a7123a7f2579e 100644
--- a/math/mathcore/inc/TMath.h
+++ b/math/mathcore/inc/TMath.h
@@ -548,7 +548,8 @@ struct CompareDesc {
 
    CompareDesc(T d) : fData(d) {}
 
-   bool operator()(int i1, int i2) { 
+   template<typename Index>
+   bool operator()(Index i1, Index i2) { 
       return *(fData + i1) > *(fData + i2);
    }
 
@@ -560,7 +561,8 @@ struct CompareAsc {
 
    CompareAsc(T d) : fData(d) {}
 
-   bool operator()(int i1, int i2) { 
+   template<typename Index>
+   bool operator()(Index i1, Index i2) { 
       return *(fData + i1) < *(fData + i2);
    }