I don't understand how it works,I mean he is passing _field to the getHeader but he is comparing the same string because field will be the same right?
it's hard to explain but field will be the same variable in the message sorter class and we are sending _field as the argument so aren't we just comparing the same string to the same string?
also he doesn't actually implement the getHeader function.
I think the idea is that different messages can have different headers for the same field. In the example on how to use it he forgot to pass the field that he wanted to sort by to the MessageSorter constructor.
1 2 3
// Sort messages by their "From:" header fields.
MessageSorter comparator("From");
sort(messages.begin(), messages.end(), comparator);