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;
    }
}

@@ -47,327 +47,91 @@
 ort 
-org.joda.time.DateTime;%0Aimport org.joda.time.format.DateTimeFormat;%0Aimport org.joda.time.format.DateTimeFormatter;%0A%0Aimport java.util.Comparator;%0A%0Aimport ca.etsmtl.applets.etsmobile.model.Moodle.MoodleCourse;%0Aimport ca.etsmtl.applets.etsmobile.model.Moodle.MoodleCourses;%0Aimport ca.etsmtl.applets.etsmobile.model.Seances
+java.util.Comparator;%0A%0Aimport ca.etsmtl.applets.etsmobile.model.Moodle.MoodleCourse
 ;%0A%0A/
@@ -552,16 +552,107 @@
 (5,6);%0A%0A
+        if (shortname1.equals(%22cu.l%22) %7C%7C shortname2.equals(%22cu.l%22))%0A            return 0;%0A%0A
         

Return 0 if a shortname equals to "cu.l"