*To*: 373704@bugs.debian.org*Subject*: Bug#373704: sort -k does not count fields the same as gnu sort*From*: Frans Pop <elendil@planet.nl>*Date*: Sat, 13 Jan 2007 13:50:15 +0100*Message-id*: <[🔎] 200701131350.28886.elendil@planet.nl>*Reply-to*: Frans Pop <elendil@planet.nl>, 373704@bugs.debian.org

severity 373704 critical found 373704 1:1.1.3-3 thanks I had meant to look into this much earlier, but unfortunately it slipped my mind. Severity critical as this behavior can cause hard to trace unpredictable behavior in any script using sort with a delimiter, potentially leading to random breakage in unrelated software. With the following test file: a c a b b c a a b # sort -k1 test a a b a c a b b c # sort -k2 test a a b b b c a c a # sort -k3 test a c a a a b b b c Conclusion: when testing _without_ delimiter, the sort is correct. With a slightly modified test file: a/c/a b/b/c a/a/b # sort -k1 -t/ test a/a/b a/c/a b/b/c # sort -k2 -t/ test a/a/b b/b/c a/c/a # sort -k3 -t/ test a/a/b b/b/c a/c/a Conclusion: when sorting with delimiter on the last field, the last-but-one field is sorted instead. With a leading delimiter in the test file: /a/c/a /b/b/c /a/a/b # sort -k1 -t/ test /a/a/b /a/c/a /b/b/c # sort -k2 -t/ test /a/a/b /a/c/a /b/b/c # sort -k3 -t/ test /a/a/b /a/c/a /b/b/c Conclusion: with a leading delimiter, the sort is somehow _always_ done on the first field. It looks like sorting with a specific delimiter set is completely broken. Tests were done inside Debian Installer. The testcase included in the busybox testsuite seems to work only by accident as it is a numeric sort and the last field to be sorted is the only numerical data in each line.

**Attachment:
pgpZSLA4cLR80.pgp**

**Follow-Ups**:**Processed: Bug#373704: sort -k does not count fields the same as gnu sort***From:*owner@bugs.debian.org (Debian Bug Tracking System)

**Bug#373704: sort -k does not count fields the same as gnu sort***From:*Frans Pop <elendil@planet.nl>

**Bug#373704: sort -k does not count fields the same as gnu sort***From:*Frans Pop <elendil@planet.nl>

**Bug#373704: sort -k does not count fields the same as gnu sort***From:*Steve Langasek <vorlon@debian.org>

**Bug#373704: sort -k does not count fields the same as gnu sort***From:*Frans Pop <elendil@planet.nl>

- Prev by Date:
**Processed: Bug#373704: sort -k does not count fields the same as gnu sort** - Next by Date:
**Re: Debian has failed us** - Previous by thread:
**Bug#396109: localechooser: Please include English "translations" for shortlists** - Next by thread:
**Processed: Bug#373704: sort -k does not count fields the same as gnu sort** - Index(es):