T O P I C R E V I E W |
Mats77sv |
Posted - 09/26/2014 : 08:21:50 AM Origin Ver. and Service Release (Select Help-->About Origin): 9pro Operating System:win7
Hi,
I have a problem sorting 11 columns (col(24) to col(34)) with respect to the first column, col(24). For instance, if I after sorting look at all rows with a values of “5” in col(24), the order of which the rows appears seen more or less random. I can see that because I have "time" in one of the other sorted columns, col(33). I have used:
wsort bycol:=24 c1:=24 c2:=34 missing:=1;
Is there anyone who knows what is wrong?
|
3 L A T E S T R E P L I E S (Newest First) |
greg |
Posted - 09/29/2014 : 09:21:25 AM When you sort on only one column, there is no guarantee that order will be preserved in the sort group when all values are the same. Sorting would actually be slowed down by such a requirement.
To do that you would need a secondary sort group, but since none of your other columnns would guarantee no order change then you need to create a column that does. A column filled with row numbers should do the trick:
// BEGIN SCRIPT wks.col = 25; // Locate insertion point wks.insert(TEMPSORT); // Insert a temporary column get col(24) -e last; // Find how much data to sort col(TEMPSORT) = data(1,last); // Fill temp column with row values dataset sbc = {24, 25}; // Select the columns for the primary sort and the secondary sort dataset sodr= {1, 1}; // Select the sort order: col(24)--ascending, col(25)--ascending wsort nestcols:=sbc order:=sodr c1:=24 c2:=35 missing:=1; //Perform the nested sorting del col(TEMPSORT); // END SCRIPT
|
Mats77sv |
Posted - 09/28/2014 : 4:13:56 PM It is not exactly what I want so I will try to explain it again.
I want to sort all the rows from col(24) to col(34) with respect to col(24). Example: After sorting, I have ex. 3 rows (ex. row no. 6, 12, and 51) with similar values in col(24) – ex. “5”. These 3 rows should be arranged in the same order of appearing (6, 12, and 51) - right after each other. However, as it is now, they appear in the order 12, 51, and 6. Hope it makes more sense now.
If I use the loop-command you suggest I will sort column by column and split up the rows.
|
greg |
Posted - 09/26/2014 : 09:03:44 AM Your command should reorder rows in columns 25 to 34 by sorting column 24. The only column which would be in sorted order is column 24.
If you want each of those columns sorted individually, then you would need a loop:
loop(jj,24,34) { wsort bycol:=jj c1:=jj c2:=jj missing:=1; }
|
|
|