On 8/15/23 05:08, Budi wrote: > so many did and hoped, the most recent: > > https://stackoverflow.com/questions/76892900/sort-text-page-based-on-5th-column-out-of-6-columns-being-troubled-with-as-the
I implemented negative keys and came up with some basic tests for them: https://github.com/landley/toybox/commit/8deb5891fb4c Translating the relevant new tests from toybox-ese: +toyonly testcmd 'negative -k' '-k-2,-2 -k-1r' 'a b z\nd e q\nx e a\nb m n\n' \ + '' 'a b z\nd e q\nb m n\nx e a\n' echo -ne 'a b z\nd e q\nb m n\nx e a\n' | sort -k-2,-2 -k-1r a b z d e q x e a b m n +toyonly testcmd 'negative -k2' '-k-2' 'a b z\nx e a\nd e q\nb m n\n' \ + '' 'a b z\nd e q\nb m n\nx e a\n' echo -ne 'a b z\nd e q\nb m n\nx e a\n' | sort -k-2 a b z x e a d e q b m n +toyonly testcmd 'negative straddle' '-k-1r' 'm n o\nj k\ng h i\nd e\na b c\n' \ + '' 'a b c\nd e\ng h i\nj k\nm n o\n' $ echo -ne 'a b c\nd e\ng h i\nj k\nm n o\n' | sort -k-1r m n o j k g h i d e a b c +toyonly testcmd 'missing negative' '-k-3r' 'm n o\ng h i\na b c\nd e\nj k\n' \ + '' 'a b c\nd e\ng h i\nj k\nm n o\n' $ echo -ne 'a b c\nd e\ng h i\nj k\nm n o\n' | ./sort -k-3r m n o g h i a b c d e j k Haven't implemented negative offsets yet (it currently just ignores them)... Rob