I have N lists of items
eg:
A, B, C, D
1, 2, 3
V, W, X, Y, Z
They are flattened into a single long list, and the user chooses an ordering to their liking
eg:
1, C, X, 3, B, A, Y, Z, 2, W, D, V
I need to re-order my N original lists so their relative sort order matches that in the user's ordering
eg:
C, B, A, D
1, 3, 2
X, Y, Z, W, V
The simple brute-force approach is to create N new empty containers, loop over the user's ordering and add each item into the relevant container as it is encountered.
Is there a more elegant approach?