Cast setting and comparisons as numbers

In f1b3702387ece053d61940b655511b9b717580b1 I removed some checking for
types which caused the check to compare by string, not number (which
would put 95 ahead of 981). Previously, if the popularity somehow got
converted to a string, it would drop it completely from the popularity
(plop it at the end). This commit forces the setting and comparisons to
numbers so that it all compares correctly. Thanks to @muddr for the
assistance.