Sort worksheet based on selected columns
X-Function not designed for Auto GetN Dialog.
1. wsort descending:=1; 2. wsort descending:=1 bycol:=2 c1:=1 c2:=3; 3. wsort bycol:=1 irng:=(2[5]:3[8],5[5]:6[8]); 4. wsort bycol:=1 irng:=(1:2,4:end);
Please refer to the page for additional option switches when accessing the x-function from script
Input/Output
Worksheet
Specified worksheet to sort
Input
int
Specified the column data as the sort criteria. It is used when you want to sort worksheet by one column.
Specified sorting by descending or ascending order.
Whether to Sort by Numeric Suffix
vector
indices of columns used as sorting criteria. It is used when you want to sort worksheet by multiple columns
sorting order index, 1 ascending, 0 descending. Its size should match the one of Nested Sort Columns.
Start index of columns selected for sorting.
End index of columns selected for sorting.
Start index of rows selected for sorting.
End index of rows selected for sorting
Whether the missing value as largest.
range
Specified ranges to sort. The range can be non-contiguous. If it has an effective value, c1, c2, r1, r2 will be ignored.
This function is used to sort the worksheet by some column bycol (as index). Or nested sorted by some columns nestcols, then we can also set descending or ascending by each column order. We can specified the range(start row, end row, start column, end column or range variable irng) to sort. We can also sort by numeric suffix column(as index).
/* This example uses the wsort X-Function to perform nested sorting. The data will be reordered so that the height column is in descending order. If there are multiple rows with the same height, these rows will be sorted by the weight column in ascending order. 1. Import the sample data into a book in Origin; 2. Sort the data with the wsort X-Function. */ //Create a new workbook newbook result:=bkname$; //Import a file path$ = system.path.program$ + "Samples\Statistics\"; fname$ = path$ + "body.dat"; impasc; dataset sbc = {4, 5}; //Select the columns for the primary sort and the secondary sort dataset sodr= {0, 1}; //Select the sort orders: col(4)--descending, col(5)--ascending wsort nestcols:=sbc order:=sodr; //Perform the nested sorting
Keywords:nested sort