My data set is grouped by "event" and "region":
groupedData: Array(14)
0: [{…}]
1: (3) [{…}, {…}, {…}]
2: [{…}]
3: [{…}]
4: Array(3)
0: {id: 326, event: "SUPPORT", region: "X", …}
1: {id: 397, event: "SUPPORT", region: "X", …}
2: {id: 298, event: "SUPPORT", region: "X", …}
length: 3
__proto__: Array(0)
5: (2) [{…}, {…}]
6: (9) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
7: Array(5)
0: {id: 483, event: "COVID", region: "IV", …}
1: {id: 448, event: "COVID", region: "IV", …}
2: {id: 549, event: "COVID", region: "IV", …}
3: {id: 600, event: "COVID", region: "IV", …}
4: {id: 634, event: "COVID", region: "IV", …}
length: 5
__proto__: Array(0)
8: Array(4)
0: {id: 118, event: "COVID", region: "IX", …}
1: {id: 922, event: "COVID", region: "IX", …}
2: {id: 959, event: "COVID", region: "IX", …}
3: {id: 856, event: "COVID", region: "IX", …}
length: 4
__proto__: Array(0)
9: Array(1)
0: {id: 747, event: "COVID", region: "V", …}
length: 1
__proto__: Array(0)
10: (5) [{…}, {…}, {…}, {…}, {…}]
11: (3) [{…}, {…}, {…}]
12: (6) [{…}, {…}, {…}, {…}, {…}, {…}]
13: (6) [{…}, {…}, {…}, {…}, {…}, {…}]
length: 14
As you can see the problem is with "region IX" because it is sorting ASC. There are many converters/functions to convert Roman Numerals to numbers for comparisons, so I am not too concerned about that.
What has me puzzled is how to use splice or slice to move the region IX array, wherever it may occur, to a position before the "X" array (if there is one) or after the "VIII" array (or whatever becomes before it if there is none), but still under the same "event"? Also, can this be accomplished without looping?
Utilizing JavaScript, jQuery and in ES5 only.