OCCRA
Go to Post For guys, is the appropriate term "manpris". ? - Chris Fultz [more]
Home
Go Back   Chief Delphi > Technical > Programming > NI LabVIEW
CD-Events   CD-Media   CD-Spy   FRC-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 01-12-2009, 07:03 PM
Kahn! Kahn! is offline
Registered User
FRC #1379
 
Join Date: Sep 2008
Location: Norcross, GA
Posts: 22
Kahn! is an unknown quantity at this point
Sorting 2-D Arrays [Labview]

I spent about 3 hours today circumventing the idea of sorting 2-D arrays in Labview. I had a 2-D array of 3 values. My plan was to reorder the array by one of the values while keeping the other values in the same index.

For example, this array:

[0] 6 14 28
[1] 7 81 4
[2] 1 15 38

I would want to sort it by column 3 making it this:
[0] 7 81 4
[1] 6 14 28
[2] 1 15 38

Does anyone know of a simple way to do this, or should I stick with my excessive, hard-to-follow code that I don't think I'll ever understand now that I've finished writing it?
Reply With Quote
  #2   Spotlight this post!  
Unread 01-12-2009, 07:10 PM
psy_wombats's Avatar
psy_wombats psy_wombats is offline
Registered User
AKA: A. King
FRC #0467 (Duct Tape Bandits)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Shrewsbury MA
Posts: 95
psy_wombats has a spectacular aura aboutpsy_wombats has a spectacular aura aboutpsy_wombats has a spectacular aura about
Re: Sorting 2-D Arrays [Labview]

With only three elements, it may be enough to avoid "sorting" sorting altogether, and just use a few IF statements. Not practical for larger sorts, but it might be best in this case.
Reply With Quote
  #3   Spotlight this post!  
Unread 01-12-2009, 08:21 PM
Uberbots's Avatar
Uberbots Uberbots is offline
Mad Programmer
AKA: Billy Sisson
FRC #1124 (ÜberBots)
Team Role: College Student
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Avon
Posts: 739
Uberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond repute
Re: Sorting 2-D Arrays [Labview]

have you considered storing the 2d array as a 1-d array of clusters? that way you could store the item you want to sort by in the first slot and just do a 1-d built in sort.
__________________
A few of my favorite numbers:
175 176 177 195 230 558 716 1024 1071 1592 1784 1816
RPI 2012
BREAKAWAY
Reply With Quote
  #4   Spotlight this post!  
Unread 01-12-2009, 08:28 PM
Kahn! Kahn! is offline
Registered User
FRC #1379
 
Join Date: Sep 2008
Location: Norcross, GA
Posts: 22
Kahn! is an unknown quantity at this point
Re: Sorting 2-D Arrays [Labview]

Quote:
Originally Posted by Uberbots View Post
have you considered storing the 2d array as a 1-d array of clusters? that way you could store the item you want to sort by in the first slot and just do a 1-d built in sort.
As a matter of fact, I just got the same response from one of our mentors (aka my brother) and it's working perfectly.

Thanks.
Reply With Quote
  #5   Spotlight this post!  
Unread 01-12-2009, 08:58 PM
Greg McKaskle Greg McKaskle is offline
Registered User
no team (Team NI)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 3,952
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Sorting 2-D Arrays [Labview]

Unfortunately, there is no easy way to tell LV exactly how to sort more complicated data containers. LV deals with almost any type, but only 1D containers, sorted by first, then second, etc, and only in ascending order.

The attached snippet shows how to build an index array, then rebuild the 2D array based upon the indices.

Greg McKaskle
Attached Thumbnails
Click image for larger version

Name:	Sort 2D.png
Views:	1874
Size:	3.8 KB
ID:	7136  
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
2008 Match Sorting Algorithm Grant Cox Rules/Strategy 1 01-09-2008 08:41 PM
Sorting out Digital NASA TV Billfred General Forum 2 12-03-2007 05:55 PM
pic: Sorting drill bits Andy Baker Extra Discussion 12 02-16-2005 08:46 PM
Arrays on the PIC? scitobor 617 Programming 8 12-06-2004 08:10 AM
EduCAD and Arrays!!!!! Sachiel7 Programming 14 11-03-2003 02:21 AM


All times are GMT -5. The time now is 07:13 AM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi