I have the following sets of files:

Every file is discribed as follow `type-ID-pageNumber-R.xml` i.e jugement\_017\_3

**set 1:**

```
 - Conclusions-009-1-R.xml   
 - Conclusions-010-1-R.xml 
 - Conclusions-011-1-R.xml

```

**set 2:**

```
 - Assignation-043-1-R.xml    
 - Assignation-043-2-R.xml 
 - Assignation-045-1-R.xml 

```

**set 3:**

```
 - Jugement-017-1-R.xml     
 - Jugement-017-2-R.xml  
 - Jugement-017-3-R.xml 
 - Jugement-018-1-R.xml 
 - Jugement-018-2-R.xml 

```

---

I want to combine `set 1`, `set 2` and `set 3` into `set 4` by using the following rules:

1. Random order of combination (every time we want to combine the files, the order in set 4 will change)
2. Files of the same **type** can be placed one after the other **if** they have the same **ID**

---

**Set 4:**

```
- Conclusions-009-1-R.xml 
- Jugement-018-1-R.xml 
- Jugement-018-2-R.xml 
- Assignation-043-1-R.xml    
- Assignation-043-2-R.xml
- Conclusions-010-1-R.xml 
- Assignation-045-1-R.xml 
- Conclusions-011-1-R.xml
- Jugement-017-1-R.xml     
- Jugement-017-2-R.xml  
- Jugement-017-3-R.xml

```

---