Hi, I think there may be a bug in OpenBSD's sort utility. The bug is that when -c is used in combination with a key field, a "top level" sort is performed when the key field does not have disorder. This differs from what might be expected and certainly from what occurs with other versions of sort.
Given the input file 'unsorted_csv': AAAA,aaaa,AAAA AAAA,AAAA,AAAA AAAA,bbbb,AAAA AAAA,BBBB,AAAA AAAA,cccc,AAAA AAAA,CCCC,AAAA On Linux: $ sort -c -t , -k 2f unsorted_csv $ echo $? 0 On OpenBSD: $ sort -c -t , -k 2f unsorted_csv sort: unsorted_csv:2: disorder: AAAA,AAAA,AAAA $ echo $? 1 The patch below seems to fix this issue. Thanks, Richard diff --git file.c file.c index 9d84d7cb4f6..b6bbf1e2b4c 100644 --- file.c +++ file.c @@ -387,7 +387,8 @@ check(const char *fn) printf("; cmp1=%d", cmp); if (!cmp && sort_opts_vals.complex_sort && - !(sort_opts_vals.uflag) && !(sort_opts_vals.sflag)) { + !(sort_opts_vals.uflag) && !(sort_opts_vals.sflag) && + !(sort_opts_vals.kflag)) { cmp = top_level_str_coll(s2, s1); if (debug_sort) printf("; cmp2=%d", cmp);