"comm --check-order" does not detect all cases of misordered input.
$ cat foo1
Reaganomics
Reagan
$ cat foo2
Reaganomics
Reagan
Clinton
$ comm --check-order foo1 foo2
Reaganomics
Reagan
comm: file 2 is not in sorted order
$ comm --check-order foo2 foo1
Reaganomics
Reagan
comm: file 1 is not in sorted order
$ comm --check-order foo1 foo1
Reaganomics
Reagan
As you can see, File foo1 is being considered well-ordered. Likewise this file:
$ cat foo
Reagan
Reaganom
R
Richard
R
Reaganomics
Reagan
$ comm --check-order foo foo
Reagan
Reaganom
R
Richard
R
Reaganomics
Reagan
Attached is a fix. Feel free to add a unit test for this; I'm not familiar
enough with coreutils to do that.
Bruno