キャンセル
次の結果を表示 
次の代わりに検索 
もしかして: 

3D tables Data Sorting

解決済み
解決策を見る

Hi all

 

I have 3D table, I need to convert it to 2D to make some data sorting and then convert it back to 3D table. I created a code that works if I deal with each page of the 3d table alone.

I then added this part of code inside a loop to be able to deals with all pages of the 3d table at once. but I does not work although it is the same code.

 

Please see the attached VI and help me with this problem.

0 件の賞賛
メッセージ1/10
4,659件の閲覧回数

Why are you using the First Call function inside the loop?  The First Call function only returns true once after clicking the run button.  During any additional iterations of the for loop, it will always return false. 

 

I'm not sure what your sorting algorithm is doing and I don't have the time to try to figure it out but OpenG toolkit has a sorting VI for a 2D array.  It could simplify your code greatly and may be worth checking out.  It may give you some ideas if your own sorting algorithm is necessary.

2018-11-16_8-49-40.png

aputman
0 件の賞賛
メッセージ2/10
4,646件の閲覧回数

What you are doing is not really "sorting" in the classic sense. It seems you are picking all unique elements from the third column, then for each, listing the values of the fourth column in the order they appear.

 

This seems like a perfect scenario for a variant based solution. try it! (For some ideas, you might be able to modify my old code here)

 

(Note that the default values if the "input" array seems incorrect compared to "2D table". It might help fixing that for easier testing)

0 件の賞賛
メッセージ3/10
4,617件の閲覧回数

@altenbach wrote:

 

This seems like a perfect scenario for a variant based solution. try it! (For some ideas, you might be able to modify my old code here)

 


See if this works for you (LV 2013)... (The error wires prevent error popups in case a key is an empty string)

 

Process3D.png

 

0 件の賞賛
メッセージ4/10
4,612件の閲覧回数

Hello Altenbach,

 

Thank you for your response. Your code does what I look for, except for that it sorts the rows of he output table according to the WRE Names (2nd coloumn of the input table). I need it to keep the order in the output as it is in the input.

Besides, I really wanted to know what is the error i made in my VI in order to learn from my own mistakes. I could not get why would'nt a running subVI work as expected if enterd in in a loop

 

Thank you again

 

0 件の賞賛
メッセージ5/10
4,587件の閲覧回数

Your code is too convoluted to really troubleshoot. I won't sit here for an hour to sift through it if a much simpler solution already exists. 😄

 

Yes, my code returns the entries sorted by the key automatically (which seems like a good thing), but it would be trivial to restore the original order at the end with a tiny little bit more code. Try it!

0 件の賞賛
メッセージ6/10
4,579件の閲覧回数
解決策
受理者 AboHareth

@altenbach wrote:

 

Yes, my code returns the entries sorted by the key automatically (which seems like a good thing), but it would be trivial to restore the original order at the end with a tiny little bit more code. Try it!


Here's one simple possibility to do that. (There are of course many different ways, so this is just one).

 

MaintainOrder.png

0 件の賞賛
メッセージ7/10
4,573件の閲覧回数

Thank you Altenbach,

 

Exactly what I wanted. Perfect 

0 件の賞賛
メッセージ8/10
4,541件の閲覧回数

Note that my solution is general does not assume that the equal items in the third (key!) column are adjacent. If they are guaranteed to be adjacent, an even much simpler solution is possible. Try it. 😄

 

Your problem description does not specify this requirement, but your sample data does. It is not clear if this is just by accident. 😉

It is important to specify the problem exactly! 😄

0 件の賞賛
メッセージ9/10
4,533件の閲覧回数

@altenbach wrote:

Note that my solution is general does not assume that the equal items in the third (key!) column are adjacent. If they are guaranteed to be adjacent, an even much simpler solution is possible. Try it. 😄 


Here's a simpler solution if we can guarantee that equal elements of the third column are adjacent. (Please verify correct operation. For the test data, it gives the correct output).

 

Process3Dsimpler.png

 

(Note that this seems similar to your own original solution, just much less convoluted. Maybe you can compare to see where the problem was.;))

0 件の賞賛
メッセージ10/10
4,528件の閲覧回数