I have the following dataframe: 

```
YearMonth   Total Cost
2015009     $11,209,041 
2015010     $20,581,043 
2015011     $37,079,415 
2015012     $36,831,335 
2016008     $57,428,630 
2016009     $66,754,405 
2016010     $45,021,707 
2016011     $34,783,970 
2016012     $66,215,044 

```

YearMonth is an int64 column. A value in YearMonth such as 2015009 stands for September 2015. I want to re-order the rows so that if the last 3 digits are the same, then I want the rows to appear right on top of each other sorted by year. 

Below is my desired output: 

```
YearMonth   Total Cost
2015009     $11,209,041 
2016009     $66,754,405     
2015010     $20,581,043 
2016010     $45,021,707    
2015011     $37,079,415 
2016011     $34,783,970   
2015012     $36,831,335 
2016012     $66,215,044
2016008     $57,428,630

```

I have scoured google to try and find how to do this but to no avail.