Fix sort order of `DiffByteRecord::Modify`
The following has been sorted non-deterministically (because it resulted
in a comparison of result Equal):
file_a.csv with first column as key:
5,foo,bar
6,baz,quux
file_b.csv with first column as key:
6,bazt,quux
5,foo_doo,bar
...so it could result in the following (wrong) sort order: file_diff_result.csv:
-,6,baz,quux
+,6,bazt,quux
-,5,foo,bar
+,5,foo_doo,bar
The result of the above will now always be: file_diff_result.csv:
-,5,foo,bar
+,5,foo_doo,bar
-,6,baz,quux
+,6,bazt,quux
The reason for the bug was a comparison result of Equal,
when "interleaved" Modify rows had the following structure:
- line number of
Deletepart offile_ais equal to line number ofAddpart offile_b - line number of
Deletepart offile_bis equal to line number ofAddpart offile_a
This now always resolves to either:
-
Less(Deletepart offile_a<Deletepart offile_b) or -
Greater(Deletepart offile_a>Deletepart offile_b) Note: previous logic has already handled the case: -
Deletepart offile_a==Deletepart offile_bso no change of logic is needed for that case
Thank you @datatraveller1 for reporting the bug: => https://github.com/dathere/qsv/issues/2443#issuecomment-2598987465