#include <set>
#include <iostream>

struct KVP
{
    std::string key, value;

    KVP(const std::string& k, const std::string& v)
        : key(k), value(v)
    {
    }

    bool operator<(const KVP& other) const
    {
        return value < other.value;
    }
};

int main()
{
    std::set<KVP> orderedpairs;
    orderedpairs.insert(KVP("key1", "z"));
    orderedpairs.insert(KVP("key2", "k"));
    orderedpairs.insert(KVP("key3", "b"));

    for (std::set<KVP>::const_iterator it = orderedpairs.begin();
         it != orderedpairs.end();
         ++it)
    {
        std::cout << "k: '" << it->key <<   "'\n" <<
                     "v: '" << it->value << "'\n";
    }
}
