#include <iostream>
#include <fstream>
#include <string>
#include <cctype>
#include <algorithm>
#include <iterator>

// függvényszerű objektum: "functor"
struct my_less
{
    bool operator()(const std::string& s1, const std::string& s2)
    {
        std::string us1 = s1;
        std::string us2 = s2;

    // TODO: locale object használata: ékezetes betűk!
        transform( s1.begin(), s1.end(), us1.begin(), toupper);
        transform( s2.begin(), s2.end(), us2.begin(), toupper);

        return us1 < us2;
    }
};

using namespace std;

int main()
{
    ifstream if1("file1.txt");
    ifstream if2("file2.txt");

    merge( istream_iterator<string>(if1), istream_iterator<string>(),
           istream_iterator<string>(if2), istream_iterator<string>(),
           ostream_iterator<string>(cout,"\n"), my_less() );
    return 0;
}