The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum
 Origin Forum
 sorting into a new column

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
schneide Posted - 11/08/2017 : 08:35:26 AM
Origin Pro 2017
b9.4.0.220
Win7


I would like to sort col A and B on Col A
with the results in col C and D, i.e while retaining the original unsorted data in Col a and B.
How can I do this?

Giselher
5   L A T E S T    R E P L I E S    (Newest First)
schneide Posted - 11/13/2017 : 03:10:48 AM
Nearly there.....

Thanks, this solved the simplified question I put forward but didn't solve my problem entirely.

I would like to use the sheet as a template and copy new data into Columns A and B. This template contains further columns with different data. So the title should better have been "sorting into an existing column"

Above solution adds new columns to the end of the worksheet each time I execute the calculation. However I would like to place the results in exactly the columns C and D (designated as Col("xsort") and Col("ysort")).

I tried using wks.col("xsort").svrm=0; to make the column accessible to sorting after copying, but I didn't manage to make it work.

I could imagine that
1. deleting the old columns C and D
2. using above solution
3. moving the columns to the correct position within the worksheet
might do the job. But isn't there an easier solution?

Giselher
Hideo Fujii Posted - 11/09/2017 : 2:10:14 PM
Hi Giselher,

Please try the following script.
//////////////////////////////////////////////
sortkeycol=1;       //column# to be sorted
int ncol=wks.ncols; //# of cols
colcopy irng:=[%H]!(1,$(ncol)) orng:=[%H]!wcol(ncol+1); //append duplicated cols
wsort w:=<active> irng:=($(ncol+1):end) bycol:=$(sortkeycol) descending:=0; //sort duplicated cols
//////////////////////////////////////////////
I hope this does your job.

--Hideo Fujii
OriginLab
schneide Posted - 11/09/2017 : 08:46:15 AM
Unfortunately both methods don't work for me.

Hideos suggestion operates only on one column, but I want to sort the value PAIRS from A and B according to the column A .

nick's suggestion comes closer but needs manual copying which I would like to avoid. When Columns C and D are the results of an automated copying process, a different operation on these columns(such as sorting) is blocked, as I understand.

I want to create a template that automatically updates. Columns A and B are the results of a calculation between other columns.

so the input is:

A B
3 7
1 8
2 9

and the output should be as follows -->

A B C D
3 7 1 8
1 8 2 9
2 9 3 7


Giselher
nick_n Posted - 11/08/2017 : 12:54:46 PM
The same result as Hideo's way will give following:
Copy your original data to C and D columns, select C and D -> right click -> Sort columns -> Ascending (Descending)BR,

Nikolay
Hideo Fujii Posted - 11/08/2017 : 11:14:02 AM
Hi Giselher,

You can enter the following dataset formula in F(X) row header of column C:
sort(A)
One handy trick is to use the following variation of the formula:
sort(wcol(j-2))
Here, "wcol" is the column indicated by the formula with variables, and "j" is a variable to indicate the current
column position. So, this formula is always applicable at any column position to refer to the 2nd column left
of the current(=j) column.

This works for you?

--Hideo Fujii
OriginLab

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000