private double[] sort_intervals(double[] unsorted_intervals) {
		int i, length;
		double min = unsorted_intervals[0];
		double max = unsorted_intervals[0];
		double[] sorted_intervals = new double[unsorted_intervals.length];
		double[] intervals;
		for (i=0; i < unsorted_intervals.length; i++) {
			if (max<unsorted_intervals[i]) {
				max=unsorted_intervals[i];
			}
			if (min>unsorted_intervals[i]) {
				min=unsorted_intervals[i];
			}
		}
		
		length = 0;
		sorted_intervals[length] = min;
		length = 1;
		
		while (min != max) {
			for (i=0; i < unsorted_intervals.length; i++) {
				//remove all values equal to min by setting them to max
				if (unsorted_intervals[i] <= min) {
					unsorted_intervals[i]=max;
				}
			}
			//find the new min
			min = max;
			for (i=0; i < unsorted_intervals.length; i++) {
				if (min>unsorted_intervals[i]) {
					min=unsorted_intervals[i];
				}
			}
			
			sorted_intervals[length] = min;
			length = length + 1;
		}
			
		//create a new set of intervals with duplicates removed
		intervals = new double[length];
		for (i=0; i < intervals.length; i++) {
			intervals[i] = sorted_intervals[i];
		}
		
		return intervals;
	}