Consider
1 3 5
3 5 7
4 5 8
Compare 1×3 with 2×1 if they match, it's fine, move on.
If they don't, then 1. go back an element the previous row, compare again, consider the inequality and decide which one to be added first.
Do the same for the next rows.
P.S. duplicate should also be considered.