Index: trunk/src/tmcsim/cadsimulator/Coordinator.java
===================================================================
--- trunk/src/tmcsim/cadsimulator/Coordinator.java	(revision 466)
+++ trunk/src/tmcsim/cadsimulator/Coordinator.java	(revision 471)
@@ -837,5 +837,7 @@
             public int compare(String o1, String o2) 
             {
-                return extractInt(o1) - extractInt(o2);
+                // extract just the timestamp from the strings and convert them to int
+                // fixes #181
+                return extractInt(o1.substring(0,8)) - extractInt(o2.substring(0,8));
             }
             // extract an integer from a String    
@@ -843,6 +845,14 @@
             {   // remove all non-digits
                 String num = s.replaceAll("\\D", "");
-                // return 0 if no digits found, else return the number
-                return num.isEmpty() ? 0 : Integer.parseInt(num);
+                try
+                {
+                    // return 0 if no digits found, else return the number
+                    return num.isEmpty() ? 0 : Integer.parseInt(num);
+                } catch (NumberFormatException ex)
+                {
+                    System.out.println("Can't convert "+s+" to integer in writeToCAD. " + 
+                    ex.getMessage());
+                    return 0;
+                }
             }
         });
