class Day implements Comparable {

    public static List<Day> buildSortedDays(List<Range> ranges)
    {

        List<IMSTimePoint> imsTimePointList = IMSTimePoint.build(ranges);

        /**
         * Create a map with keys as days and values as list of hours
         */
        Map<String, List<Integer>> timePointsMap = new HashMap<>();
        for (IMSTimePoint imsTimePoint : imsTimePointList)
        {
            String date = imsTimePoint.getDate();
            if (!timePointsMap.containsKey(date))
            {
                timePointsMap.put(date, new ArrayList<>());
            }
            timePointsMap.get(date).add(imsTimePoint.getHourIndex());
        }

        Set<Day> days = new HashSet<>();
        for (Map.Entry<String, List<Integer>> entry : timePointsMap.entrySet())
        {
            Day day = new Day(entry.getKey(), entry.getValue());
            days.add(day);
        }

        List<Day> sortedDays = new ArrayList<>(days);
        Collections.sort(sortedDays);

        return sortedDays;
    }

    public  Day(String dayStr);
    public  Day(String dayStr, List<Integer> hours);

}