Lexicographic order seems more complex than reverse lexicographic order.
In reverse lex order, it becomes straightforward:
define p(n,k) as the number of partitions of n with largest part k (alternatively with no more than k parts). It has the well known recursion p(n,k)=p(n,k-1)+p(n-k,k).
Then, for any partition, say 5311, here with sum n=10, do
p(5+3+1+1,5 -1) = 23
p(3+1+1,3 -1) = 3
p(1+1,1 -1) = 0
p(1,1 -1) = 0
add them to get 26, and subtract that from p(5+3+1+1)= 42 to get the rank = 16.
To see why this works, look at the transpose partitions counted by p(10,4), p(5,2) etc that are clipped of.