Add proper sorting of numeric plist keys

This commit is contained in:
Allan Odgaard
2013-10-07 19:03:58 +02:00
parent 9a6451da2c
commit dff40138f1

View File

@@ -166,11 +166,18 @@ namespace
return true;
else if(rhsIter != _key_ranks.end())
return false;
else if(is_numeric(lhs.first) && is_numeric(rhs.first))
return std::stol(lhs.first) < std::stol(rhs.first);
else
return lhs.first < rhs.first;
}
private:
static bool is_numeric (std::string const& str)
{
return str.find_first_not_of("0123456789") == std::string::npos;
}
std::map<std::string, size_t> _key_ranks;
};