I'm working on a hit counter page for my site, and though this seems like it should be easy, I just can't wrap my head around it.
I have a JSON object containing IPs that visit pages on my site. Here's a dummy list:
{
"/chat": {"0.0.0.0": 4, "1.1.1.1": 2, "2.2.2.2": 12},
"/js": {"0.0.0.0": 78, "1.1.1.1": 20, "2.2.2.2": 8},
"/my/page": {"0.0.0.0": 34, "1.1.1.1": 8, "2.2.2.2": 1},
}
What I need is a way to order these objects by the total hit count.
In converted order:
{
"/js": {"0.0.0.0": 78, "1.1.1.1": 20, "2.2.2.2": 8},
"/my/page": {"0.0.0.0": 34, "1.1.1.1": 8, "2.2.2.2": 1},
"/chat": {"0.0.0.0": 4, "1.1.1.1": 2, "2.2.2.2": 12},
}
I'm using NodeJS to do this, and no I'm not wanting to use a module for this. I don't know why but every response to a NodeJS question on this site gets some module referenced. Stahp.
Thanks for the help ahead of time, I'm sure the answer is pretty ridiculously obvious but I just can't seem to zone in on it.