My scenario involves working with an Immutable list to populate a drag and drop feature. The list items do not have any ids, only indices when mapped through.
const list = Immutable.List([{"alias":"cat"},{"alias":"dog"},{"alias":"rat"}])
Upon dragEnd, I receive an array representing the new order of the list, but it lacks any specific identifiers for the list items apart from the previous order's indices.
const newOrder = [{"order":1},{"order":0},{"order":2}]
I am faced with the task of dispatching a re-ordered Immutable data list based on these indices to update my store. So far, I haven't found a concise and efficient way to achieve this. My initial thoughts were to use sortBy or create an orderedMap from the original list, referencing it using the newOrder array to generate the orderedList. However, none of these approaches seem to be working effectively.
The desired dispatched result is:
const orderedList = Immutable.List([{"alias":"dog"},{"alias":"cat"},{"alias":"rat"}])
What would be the most optimal solution in this case?