The ranking of a civilization like what is shown on the demographics screen is calculated for that purpose in the Python for the screen.
Oddly, CvCity has rank related functions like findCommerceRateRank. CvPlayer does not, as far as I know.
So if you want to know the rankings for current science output, you should do something like:
1) loop over all civilizations and store their current output as gotten from CvPlayer::getCommerceRate(CommerceTypes eIndex) in an array
2) sort the array
3) bingo
Well, technically that is not all there is to it. You have to maintain the association between the player and the rating so there is some extra stuff to do in the sort - either store, and sort, data structures (perhaps each element in the array is itself a 2 element array of the output and player ID, for example) or sort 2 arrays in parallel, or some such thing.
If you don't need a full list of ranks, just one specific player's rank then you don't need to sort the array at all. Or, for that matter, create it in the first place. You can just look up that player's output and then loop over all the players who are not that player and count how many have a higher output. Add one to the count and that is the rank for that civ. (This will treat ties as the higher rank, so if you have 10, 9, 8, 8, 7 they will be rank 1, 2, 3, 3, 5; some ranking systems would call them 1, 2, 4, 4, 5 in which case you should count how many are higher or the same.)