I have the following data:
a b c d f g h i j
a b d e f h i j
a b c d e f j k l
a b c d e f g h m
I would like to output it (into Excel for example) as follows:
a b c d e f g h i j
a b d e f h i j
a b c d e f j k l
a b c d e f g h m
In excel terms I want to shift cells across so the text matches up in columns.
NOTE: I have used alphabetic ordering for simplicity but in reality there is no such ordering – but I need to maintain the original sequencing.
Updated Example:
Original Data
a b c d f g h i j
a b d e f h i j
a b c d e f j k l
a b x d e f g h m
Dougs Output
a b c d f g h i j
a b d e f h i j
a b c d e f j k l
a b d x e f g h m
My Manual Output (Required)
a b c d f g h i j
a b d e f h i j
a b c d e f j k l
a b x d e f g h m
Above x occurs at index 2 but d occurs at indices 2 and 3 therefore x should come before d.
I have solved it in Java. There is a custom compare which looks at the max and min indices of each values and sorts on that. Then I printed them out to screen.
**Note my data is in a HashMap for reasons not explained here but it could have easily been in a simple List.
**Note excuse my inexperienced coding practices.
@Doug-Glancy if you are able to do with in VB it would be great!
ValueComparator.java
App.java