Handle tab-separated ints in numeric secondary sort

Change-Id: Ie1444e15022a043a6ded838740b45ed61957f4ce
diff --git a/src/main/java/org/ids_mannheim/TotalNGrams.java b/src/main/java/org/ids_mannheim/TotalNGrams.java
index afd0670..2057676 100644
--- a/src/main/java/org/ids_mannheim/TotalNGrams.java
+++ b/src/main/java/org/ids_mannheim/TotalNGrams.java
@@ -196,9 +196,17 @@
                         if (cmp1 != 0) {
                             return cmp1;
                         } else {
-                            if (numericSecondarySort)
-                                return new BigInteger(a.getKey()).compareTo(new BigInteger(b.getKey()));
-                            else
+                            if (numericSecondarySort) {
+                                String[] columnsA = a.getKey().split("\t");
+                                String[] columnsB = b.getKey().split("\t");
+                                int len = Math.min(columnsA.length, columnsB.length);
+                                for (int i = 0; i < len; i++) {
+                                    int res = new BigInteger(columnsA[i]).compareTo(new BigInteger(columnsB[i]));
+                                    if (res != 0)
+                                        return (res);
+                                }
+                                return 0;
+                            } else
                                 return a.getKey().compareTo(b.getKey());
                         }
                     })