cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
qspringleaf
Level III

How to use JMP script to sort Data Table by two columns

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.

 

NameDateAccomplish amounts of work-->NameDateAccomplish amounts of work
John20/8/21 9:03:59100%Kevin20/8/17 9:03:5760%
Kevin20/8/22 9:03:5980%Kevin20/8/18 9:03:5740%
Kevin20/8/23 9:03:6077%Kevin20/8/19 9:03:5850%
John20/8/20 9:03:5867%Kevin20/8/20 9:03:5833%
Kevin20/8/17 9:03:5760%Kevin20/8/21 9:03:590%
John20/8/18 9:03:5760%Kevin20/8/22 9:03:5980%
Kevin20/8/19 9:03:5850%Kevin20/8/23 9:03:6077%
John20/8/19 9:03:5850%John20/8/17 9:03:5740%
Kevin20/8/18 9:03:5740%John20/8/18 9:03:5760%
John20/8/17 9:03:5740%John20/8/19 9:03:5850%
Kevin20/8/20 9:03:5833%John20/8/20 9:03:5867%
John20/8/23 9:03:6023%John20/8/21 9:03:59100%
John20/8/22 9:03:5920%John20/8/22 9:03:5920%
Kevin20/8/21 9:03:590%John20/8/23 9:03:6023%
1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: How to use JMP script to sort Data Table by two columns

  1. If you run the sort interactively
    1. Tables=>Sort
    2. 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"
    3. You will see the JSL that is required to do the Sortsort.PNG
  2. Here is a cleaned up version
    Names Default To Here( 1 );
    dt = Current data table();
    dt << Sort( By( :name, :Date ), Order( Ascending, Ascending ) );
  3. 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.

Jim

View solution in original post

4 REPLIES 4
txnelson
Super User

Re: How to use JMP script to sort Data Table by two columns

  1. If you select multiple columns, and then right click on them and select "Sort" the data table will be sorted by all selected columns.
  2. You can go to the Pull Down Menus and select     Tables==>Sort    and then select whatever columns and whatever ascending/descending combination you want.
  3. Below is a simple sorting script taken directly from the Scripting Index entry for "Sort"
    Names Default To Here( 1 );
    dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
    dt << Sort( By( :name ), Order( Ascending ) );
Jim
qspringleaf
Level III

Re: How to use JMP script to sort Data Table by two columns

thanks, but how to sort Data Table by two or multiple columns? Need sort by name first then sort by date also. thanks a lot.
qspringleaf
Level III

Re: How to use JMP script to sort Data Table by two columns

but how to use script sort Data Table by two or multiple columns? Need sort by name first then sort by date also. thanks a lot.
txnelson
Super User

Re: How to use JMP script to sort Data Table by two columns

  1. If you run the sort interactively
    1. Tables=>Sort
    2. 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"
    3. You will see the JSL that is required to do the Sortsort.PNG
  2. Here is a cleaned up version
    Names Default To Here( 1 );
    dt = Current data table();
    dt << Sort( By( :name, :Date ), Order( Ascending, Ascending ) );
  3. 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.

Jim