To Reach Rank 20 you need a total of 240 Points from medals.
You can get 2 medals in every main mission and one in every side mission.
You can get in every main Mission up to 2 gold medals, the first one for finishing the level and a second one if you get 100% in that level. That makes a total of 6 Ranking Points.
You get one gold medal, another 3 points, in every side mission if you reach a certain time.
There are 31 ranks in total
1 point for every Bronze medal
2 points for every Silver medal
3 points for every Gold medal
After every 12th point you reach the next rank.
There are a total of 57 missions, 21 main missions with double medals and 36 side missions with a single medal, that nets you a total of 78 accessible gold medals with a total of 234 points.
After finishing all levels with a gold medal you unlock time attack.
in time attack you need to finish all 21 levels in a certain time. this net you another gold medal for each main mission level. you can get here another 63 points if you rack up all gold medals. This makes a total of 297 points.
You should get rank 20 as soon as you unlock time attack mode if not play the first levels again they should be super easy for you now.
If needed i can load up a video guides for certain or all levels :)