Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

hi, I need help with this c++ program. thank you Modify the sort function to han

ID: 3719442 • Letter: H

Question

hi, I need help with this c++ program. thank you

Modify the sort function to handle an array of strings. In the main function display the array, both before, and after, the sort. After the array has been sorted, use the bSearch function (modified) to search for a string that the user has entered. If found display the message "found" along with its offset, if not found then display the message "not found". Upload the source code (cpp file) through quizzes link on left hand side of the Blackboard course page. Note: Your program must be able to handle lowercase and uppercase strings. Use the following array string str "Mike", "bob", "Bill", "william", "George", "geoffy

Explanation / Answer

#include <iostream>

#include <algorithm>

using namespace std;

int main() {

string str[] = {"Mike", "bob", "Bill"};

int N = sizeof(str)/sizeof(str[0]);

sort(str, str + N, [](const auto& left, const auto& right){

const auto final = mismatch(left.cbegin(), left.cend(), right.cbegin(), right.cend(), [](const auto& left, const auto& right){return tolower(left) == tolower(right);});

return final.second != right.cend() && (final.first == left.cend() || tolower(*final.first) < tolower(*final.second));

});

for(int i = 0; i < N; i++){

cout << str[i] << endl;

}

}

**Comment for any further queries.