Question about How to use JMP script to sort Data Table by two or multiple columns?
Normally data table can sort order by one column, just have left table shows, sort by column "Name".
but how to use JMP to sort by two column? order by both "Name" & 'Date", like the right table shows, kindly help to suggest.
thanks a lot.
| Name | Date | Accomplish amounts of work | --> | Name | Date | Accomplish amounts of work |
| John | 20/8/21 9:03:59 | 100% | Kevin | 20/8/17 9:03:57 | 60% |
| Kevin | 20/8/22 9:03:59 | 80% | Kevin | 20/8/18 9:03:57 | 40% |
| Kevin | 20/8/23 9:03:60 | 77% | Kevin | 20/8/19 9:03:58 | 50% |
| John | 20/8/20 9:03:58 | 67% | Kevin | 20/8/20 9:03:58 | 33% |
| Kevin | 20/8/17 9:03:57 | 60% | Kevin | 20/8/21 9:03:59 | 0% |
| John | 20/8/18 9:03:57 | 60% | Kevin | 20/8/22 9:03:59 | 80% |
| Kevin | 20/8/19 9:03:58 | 50% | Kevin | 20/8/23 9:03:60 | 77% |
| John | 20/8/19 9:03:58 | 50% | John | 20/8/17 9:03:57 | 40% |
| Kevin | 20/8/18 9:03:57 | 40% | John | 20/8/18 9:03:57 | 60% |
| John | 20/8/17 9:03:57 | 40% | John | 20/8/19 9:03:58 | 50% |
| Kevin | 20/8/20 9:03:58 | 33% | John | 20/8/20 9:03:58 | 67% |
| John | 20/8/23 9:03:60 | 23% | John | 20/8/21 9:03:59 | 100% |
| John | 20/8/22 9:03:59 | 20% | John | 20/8/22 9:03:59 | 20% |
| Kevin | 20/8/21 9:03:59 | 0% | John | 20/8/23 9:03:60 | 23% |
- If you run the sort interactively
- Tables=>Sort
- Then in the resulting new data table, you right click on the "Source" entry in the Tables Panel on the upper left portion of the new data table and select "Edit"
- You will see the JSL that is required to do the Sort

- Here is a cleaned up version
Names Default To Here( 1 );
dt = Current data table();
dt << Sort( By( :name, :Date ), Order( Ascending, Ascending ) );
- Also, given the example I had provided in my last entry, a guess could have been made on how to expand on it to sort 2 columns.
I strongly recommend that you take the time to read the Scripting Guide in the JMP Documentation Library.