Сортировка слиянием. Сортировка текстового файла

Нужно отсортировать файл при помощи сортировки слиянием, возникла проблема в функции. Как показывает visual studio, то ошибка в функции mergeSort. Но я не знаю как это решить

struct people
{
    string fam, dol;//у человека есть фамилия и должность
    int d, m, y;//дата,месяц,год рождения
    int staj, zarp;//это стаж и зарплата


};

//n-количество элементов в масиве
void print(people* mas, int n) {
    for (int i = 0; i < n; i++) {
        cout << mas[i].fam << " " << mas[i].dol << " ";//вывод на экран фамилию и должность 
        cout << mas[i].d << "." << mas[i].m << "." << mas[i].y << " ";//вывод на экран дату,день,месяц,год
        cout << mas[i].staj << " " << mas[i].zarp << endl;//вывод на экран стаж и зарплату
    }
};


void Vector_made(vector <int> value, int n, people* mas) {  //перевод массива в вектор 
    vector <int> value;          
    for (int i = 0; i < n; i++) {
        value.push_back(mas[i].zarp);
    }
}

//-------------------------------------------------------------------------------------------------------//

void merge(people* mas, std::vector<int>& arr, int start, int middle, int end, int n) {


    std::vector<int> leftArray(middle - start + 1);
    std::vector<int> rightArray(end - middle);

    Vector_made(leftArray, n, mas);
    Vector_made(rightArray, n,mas);
    // fill in left array
    for (int i = 0; i < leftArray.size(); ++i)
        leftArray[i] = arr[start + i];

    // fill in right array
    for (int i = 0; i < rightArray.size(); ++i)
        rightArray[i] = arr[middle + 1 + i];

    /* Merge the temp arrays */

    // initial indexes of first and second subarrays
    int leftIndex = 0, rightIndex = 0;

    // the index we will start at when adding the subarrays back into the main array
    int currentIndex = start;

    // compare each index of the subarrays adding the lowest value to the currentIndex
    while (leftIndex < leftArray.size() && rightIndex < rightArray.size()) {
        if (leftArray[leftIndex] <= rightArray[rightIndex]) {
            arr[currentIndex] = leftArray[leftIndex];
            leftIndex++;
        }
        else {
            arr[currentIndex] = rightArray[rightIndex];
            rightIndex++;
        }
        currentIndex++;
    }

    // copy remaining elements of leftArray[] if any
    while (leftIndex < leftArray.size()) arr[currentIndex++] = leftArray[leftIndex++];

    // copy remaining elements of rightArray[] if any
    while (rightIndex < rightArray.size()) arr[currentIndex++] = rightArray[rightIndex++];
}

// main function that sorts array[start..end] using merge()
void mergeSort(std::vector<int>& arr, int start, int end) {
    // base case
    if (start < end) {
        // find the middle point
        int middle = (start + end) / 2;

        mergeSort(arr, start, middle); // sort first half
        mergeSort(arr, middle + 1, end);  // sort second half

        // merge the sorted halves
        merge(arr, start, middle, end);
    }
}


Ответы (0 шт):