Stability of sorting
I would expect that the order is stable. This means that if I cancel the ordering of a column I should go back to the original order.
We could add an index object and the original order should be based on this number, or we could save the original order in a local state
Does the sorting affect the array in the global state? It really shouldn't
In our case, it should, as it affects the order of the spectra and other places such as the multiple spectra analysis list
I believe there's an alternative approach we can explore, but it would require more adjustments. We could store the order as 'Ascending' or 'Descending' in the state, and then use that information to sort spectra in all locations without modifying the global state array
I believe that making changes to the original array is the simplest way to accomplish this without introducing additional complexities
There are other less intrusive alternatives. I recommend to create derived state dynamically (after the useReducer call) that you pass in a context provider. We don't want the sorted array to be saved when we export the data.