Sort (and grade) performs a lexicographical comparison on the major cells. In this case, the major cells are rows. Something that starts with a 0 compares lexicographically less than something that starts with a 1, and something that starts with a 1 compares lexicographically less than something that starts with a 2.

Alternatives:

Sort each row: /:~"1
Sort columns: /:~&.|:
Sort each column: /:~"1&.|:

 -E

On Sun, 13 Mar 2022, 'Skip Cave' via Programming wrote:

Is this how sort is supposed to work?

sep=:10#.^:_1]


|:sep 120 to 130

1 1 1 1 1 1 1 1 1 1 1

2 2 2 2 2 2 2 2 2 2 3

0 1 2 3 4 5 6 7 8 9 0


/:~|:sep 120 to 130

0 1 2 3 4 5 6 7 8 9 0

1 1 1 1 1 1 1 1 1 1 1

2 2 2 2 2 2 2 2 2 2 3

Skip Cave
Cave Consulting LLC
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to