package ca.etsmtl.applets.etsmobile.util;

import java.util.Comparator;

import ca.etsmtl.applets.etsmobile.model.Moodle.MoodleCourse;

/**
 * Created by Steven on 2016-01-14.
 */
public class CourseComparator implements Comparator<MoodleCourse> {

    @Override
    public int compare(MoodleCourse course1, MoodleCourse course2) {
        String shortname1 = course1.getShortname().substring(3,5) + "." + course1.getShortname().substring(5,6);
        String shortname2 = course2.getShortname().substring(3,5) + "." + course2.getShortname().substring(5,6);

        if (shortname1.equals("cu.l") || shortname2.equals("cu.l"))
            return 0;

        if (Double.valueOf(shortname1) > Double.valueOf(shortname2)) {
            return 1;
        }

        if (Double.valueOf(shortname1) < Double.valueOf(shortname2)) {
            return -1;
        }

        return 0;
    }
}

package ca.etsmtl.applets.etsmobile.util;

import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

import java.util.Comparator;

import ca.etsmtl.applets.etsmobile.model.Moodle.MoodleCourse;
import ca.etsmtl.applets.etsmobile.model.Moodle.MoodleCourses;
import ca.etsmtl.applets.etsmobile.model.Seances;

/**
 * Created by Steven on 2016-01-14.
 */
public class CourseComparator implements Comparator<MoodleCourse> {

    @Override
    public int compare(MoodleCourse course1, MoodleCourse course2) {
        String shortname1 = course1.getShortname().substring(3,5) + "." + course1.getShortname().substring(5,6);
        String shortname2 = course2.getShortname().substring(3,5) + "." + course2.getShortname().substring(5,6);

        if (Double.valueOf(shortname1) > Double.valueOf(shortname2)) {
            return 1;
        }

        if (Double.valueOf(shortname1) < Double.valueOf(shortname2)) {
            return -1;
        }

        return 0;
    }
}

--- 
+++ 
@@ -1,14 +1,8 @@
 package ca.etsmtl.applets.etsmobile.util;
-
-import org.joda.time.DateTime;
-import org.joda.time.format.DateTimeFormat;
-import org.joda.time.format.DateTimeFormatter;
 
 import java.util.Comparator;
 
 import ca.etsmtl.applets.etsmobile.model.Moodle.MoodleCourse;
-import ca.etsmtl.applets.etsmobile.model.Moodle.MoodleCourses;
-import ca.etsmtl.applets.etsmobile.model.Seances;
 
 /**
  * Created by Steven on 2016-01-14.
@@ -19,6 +13,9 @@
     public int compare(MoodleCourse course1, MoodleCourse course2) {
         String shortname1 = course1.getShortname().substring(3,5) + "." + course1.getShortname().substring(5,6);
         String shortname2 = course2.getShortname().substring(3,5) + "." + course2.getShortname().substring(5,6);
+
+        if (shortname1.equals("cu.l") || shortname2.equals("cu.l"))
+            return 0;
 
         if (Double.valueOf(shortname1) > Double.valueOf(shortname2)) {
             return 1;
Return 0 if a shortname equals to "cu.l"

"cu.l" can't be converted to double
