I am trying to set up a code to reorder rows of data to put them in the optimal order, based on minimizing a value. The example I have below, I have 10 items. I want to reorder the rows to minimize the differences between values in the value1 and value2 column, value1 having a larger bias for being grouped together. Can someone help me with a code that can be used for this? Another way of putting it, I want to group like values in value1 first, and then group as much as possible in value2. I would need to be able to reuse this function over and over again for different data sets.
Any help much appreciated.
How data is given:
example1.JPG
Optimized data: (did this by hand, need to have it done automatically)
example2.JPG
Bookmarks