I am struggling to find solution for a scenario. I have few files in a directory. lets say

```
vbBaselIIIData_201802_3_d.data.20180405.txt.gz    
vbBaselIIIData_201802_4_d.data.20180405.txt.gz   
vbBaselIIIData_201803_4_d.data.20180405.txt.gz  
vbBaselIIIData_201803_5_d.data.20180405.txt.gz

```

Here suppose the single digit number after the second underscore is called runnumber. I have to pick only files with latest runnumber. so in this case I need to pick only two out of the four files and put it in a mutable scala list. The ListBuffer should contain :

```
vbBaselIIIData_201802_4_d.data.20180405.txt.gz  
vbBaselIIIData_201803_5_d.data.20180405.txt.gz

```

Can anybody suggest me how to implement this. I am using Scala, but only algorithm is also appreciated. What could be the right sets of datastructure we can use? What are the functions we need to implement? Any suggestions.