# Sorting Data Tables or 2 Arrays

## Recommended Posts

Hi people!

I'm developing a project with UniLogic v1.25.61 for the UniStream USP-104-B10.

I need to sort an entire Data Table (2 columns, A and B), sorting just one column (A), has anyone ever try this?

The other option is to have 2 arrays (A and B), sort one (A) of them and then I need to sort the other one (B) the same way I sorted the first one (A).

I don't know if I'm being clear enough so here you have an example:

Before sorting: A={1,4,2,3} B={Q,W,E,R}

After sorting just column A or array A: A={1,2,3,4} B={Q,E,R,W}

Cheers,

Gonzalo

##### Share on other sites

hi GonzaloRoldan_,

what data type are column A and B?

##### Share on other sites

Hi @ORSO2001,

The data type for both columns is INT32.

##### Share on other sites

hi,

can be the DTI sorted from the beginning or you also need to know the time order that each record was insert?

how many rows are in the DTI?

##### Share on other sites

Hi!

Sorry for the delay, but I was working on that because I needed to solve it asap.

The DTI can be sorted from the beginning.
The number of rows is variable (no more than 20).

I managed to work it out, it wasn't the most efficient way I think, but it works. If someone needs it, just tell me and I'll post it here.

Cheers people!

##### Share on other sites

hi...if the DTI can be sorted from the beginning (when this is populated) you can check the valuo of the row "0" if this value is less of the row that you have to insert increase a variable to check the next row...do so on...when the result is positive (the new value is less on the read row) you can use the "insert row" UDFB...and reset the variable to check the row.

I hope that my explaination is clear.

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×