Problem
You need to sort a table using one or more columns as the sort key.
Solution
Use the table's sort method, which supports ascending and descending order and in-place or new table sorting.
dt = Open( "$sample_data/big class.jmp" );
new table = dt << sort( by( height, weight ) );
Wait( 2 );
Close( new table, nosave );
dt << sort( by( height, weight ), order( descending ), replace table );
Wait( 2 );
Close( dt, nosave );
dt = Open( "$sample_data/big class.jmp" );
orig = dt << New Column( "original row", formula( Row() ) );
dt << runFormulas;
orig << deleteFormula;
dt << sort( by( height, weight ), order( descending ), replace table );
Wait( 2 );
dt << sort( by( orig ), order( ascending ), replace table );
Wait( 2 );
Close( dt, nosave );
Discussion
The final example shows adding a new column to capture the original sort order and how to use that new column to resore the original order. The documentation shows another useful option to name the table.
new table = dt << sort( by( height, weight ), Output Table Name("Fred") );
See Also
Documentation