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
Display Name |
Variable Name |
I/O and Type |
Default Value |
Description |
---|---|---|---|---|
Worksheet to do sorting | w |
Input/Output Worksheet |
|
Specified worksheet to sort |
Sort By Column | bycol |
Input int |
|
Specified the column data as the sort criteria. It is used when you want to sort worksheet by one column. |
Decending or ascending | descending |
Input int |
|
Specified sorting by descending or ascending order. |
sort numeric_suffix | sortnumeric |
Input int |
|
Whether to Sort by Numeric Suffix |
Nested Sort Columns | nestcols |
Input vector |
|
indices of columns used as sorting criteria. It is used when you want to sort worksheet by multiple columns |
Sort Orders | order |
Input vector |
|
sorting order index, 1 ascending, 0 descending. Its size should match the one of Nested Sort Columns. |
Column From | c1 |
Input int |
|
Start index of columns selected for sorting. |
Column To | c2 |
Input int |
|
End index of columns selected for sorting. |
Row From | r1 |
Input int |
|
Start index of rows selected for sorting. |
Row To | r2 |
Input int |
|
End index of rows selected for sorting |
Missing is Largest | missing |
Input int |
|
Whether the missing value as largest. |
Range to Sort | irng |
Input 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