Guest Posted September 28, 2007 Report Share Posted September 28, 2007 It's not easy to sort a NxM table by human. So, we can sort each one column or raw. The question is: how to sort a table if you only can sort a row or a column? For example, 3,3,2,5 4,1,8,6 => 1,2,3,3 4,5,6,8 Quote Link to comment Share on other sites More sharing options...
0 bonanova Posted September 28, 2007 Report Share Posted September 28, 2007 Use the ravel operator, then the sort operator, then the shape operator. Ravel linearizes a higher-order array. A linear array can be sorted. The sorted linear array can then be reshaped to that of the original array. At IBM, back in the 1960's, Ken Iverson invented APL "read A Programming Language" that provided operators like ravel and reshape. Google it for more information. IBM still sells a version of APL that runs on a PC. Quote Link to comment Share on other sites More sharing options...
0 Guest Posted September 28, 2007 Report Share Posted September 28, 2007 Use the ravel operator, then the sort operator, then the shape operator. There's no "ravel" or "shape" operator in this puzzle. It only has "sort" operator to sort a column or a row. Quote Link to comment Share on other sites More sharing options...
0 bonanova Posted October 3, 2007 Report Share Posted October 3, 2007 There's no "ravel" or "shape" operator in this puzzle. It only has "sort" operator to sort a column or a row. By sorting rows then columns [or v.v.] you get the smallest number to the upper left and the largest number to the bottom right, and all rows and columns sorted. Repeated sorts of rows and columns have no effect. Elements of the array are not sorted except within a row or a column. e.g. sort rows: then sort cols: 6 9 4 3 ....... 3 4 6 9 ....... 1 2 4 7 8 2 1 5 ....... 1 2 5 8 ....... 1 3 5 8 7 6 5 4 ....... 4 5 6 7 ....... 3 4 6 8 8 1 4 3 ....... 1 3 4 8 ....... 4 5 6 9 Sorting row1, col1, row2, ... col4, the result is sorted rows and cols, but not sorted table: 1 1 4 7 2 3 5 8 3 4 5 8 4 6 6 9 Once you reach a configuration where rows and cols are sorted, repeated sorting makes no change to the table. If that's all you can do, you're left with an unsorted table. To sort the table, you have to do something more than / different from sorting rows or cols. [a] sort diagonals or mess with its shape somehow. Quote Link to comment Share on other sites More sharing options...
0 Guest Posted October 3, 2007 Report Share Posted October 3, 2007 Hint: Sort has two kinds. One is Ascending sort, the other is descending one. Quote Link to comment Share on other sites More sharing options...
0 bonanova Posted October 6, 2007 Report Share Posted October 6, 2007 Question -- are you allowed to look at the table, and use row/col sorts to make the table sorted??? If so, you can use sort_up and sort_down to manipulate numbers to their correct positions, much like solving the "15" puzzle. I'm assuming you're asking for a procedure to sort tables that could be programmed to sort any and all tables without human "guidance". Quote Link to comment Share on other sites More sharing options...
0 bonanova Posted October 12, 2007 Report Share Posted October 12, 2007 Bumping this to the top so maybe the author will reply to the last question. Thanks ...! Quote Link to comment Share on other sites More sharing options...
Question
Guest
It's not easy to sort a NxM table by human. So, we can sort each one column or raw.
The question is: how to sort a table if you only can sort a row or a column?
For example,
3,3,2,5
4,1,8,6
=>
1,2,3,3
4,5,6,8
Link to comment
Share on other sites
6 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.