#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main() {
	map<string, int, function<bool(const string&, const string&)>> myMap([ordering = { "dog", "cat", "mouse", "elephant" }](const auto& lhs, const auto& rhs) { return find(cbegin(ordering), cend(ordering), lhs) < find(cbegin(ordering), cend(ordering), rhs); });

	myMap["cat"s] = 1;
	myMap["dog"s] = 2;
	myMap["elephant"s] = 3;
	myMap["mouse"s] = 4;
	myMap["rhino"s] = 5;

	for (auto& i : myMap) {
		cout << i.first << ' ' << i.second << endl;
	}
}