public static void qsort(Work[] works, int start, int end) {
        if (start >= end) return;
        int left = start, right = end;
        int pivot = works[(left + right) / 2].start; //use the middle node's value for pivot
        while (left <= right) {
            while (works[left].start < pivot) left++;
            while (works[right].start > pivot) right--;
            if (left <= right) {
                Work tmp = works[left];
                works[left] = works[right];
                works[right] = tmp;
                left++; right--;
            }
        }
        if (left < end) qsort(works, left, end);
        if (start < right) qsort(works, start, right);
    }