Dang! And here I was getting all excited about finding out about the game!!! - dlavery [more]
 Chief Delphi Sorting 2-D Arrays [Labview]
 CD-Media CD-Spy
 portal register members calendar search Today's Posts Mark Forums Read FAQ rules

#1
01-12-2009, 07:03 PM
 Kahn! Registered User FRC #1379 Join Date: Sep 2008 Location: Norcross, GA Posts: 22
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?
#2
01-12-2009, 07:10 PM
 psy_wombats 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
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.
#3
01-12-2009, 08:21 PM
 Uberbots Mad Programmer AKA: Billy Sisson FRC #1124 (ÜberBots) Team Role: College Student Join Date: Jan 2006 Rookie Year: 2005 Location: Avon Posts: 739
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
#4
01-12-2009, 08:28 PM
 Kahn! Registered User FRC #1379 Join Date: Sep 2008 Location: Norcross, GA Posts: 22
Re: Sorting 2-D Arrays [Labview]

Quote:
 Originally Posted by Uberbots 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.
#5
01-12-2009, 08:58 PM
 Greg McKaskle Registered User FRC #2468 (Team NI & Appreciate) Join Date: Apr 2008 Rookie Year: 2008 Location: Austin, TX Posts: 4,857
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.

Attached Thumbnails

 Thread Tools Display Modes Rate This Thread Linear Mode Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 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 User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Announcements     User Announcements FIRST     General Forum         FIRST E-Mail Blast Archive     Rumor Mill     Career     Robot Showcase Technical     Technical Discussion     Robotics Education and Curriculum     Motors     Electrical         CAN     Programming         NI LabVIEW         C/C++         Java         Python     Control System         FRC Control System         Sensors     Pneumatics     Kit & Additional Hardware     CAD         Inventor         SolidWorks         Creo     IT / Communications         3D Animation and Competition         Website Design/Showcase         Videography and Photography         Computer Graphics     National Instruments LabVIEW and Data Acquisition         LabView and Data Acquisition Competition     Unsung FIRST Heroes     Awards         Chairman's Award     Rules/Strategy         Scouting         You Make The Call     Team Organization         Fundraising         Starting New Teams         Finding A Team         College Teams     Championship Event     Regional Competitions     District Events     Off-Season Events     Thanks and/or Congrats     FRC Game Design     OCCRA         OCCRA Q&A         OCCRA Programming Other     Chit-Chat         Games/Trivia             Fantasy FIRST     Car Nack's Corner     College & University Education     Dean Kamen's Inventions     FIRST-related Organizations         Western Region Robotics Forum         Southern California Regional Robotics Forum         The Blue Alliance             Video Archives     FIRST In the News...     FIRST Lego League         Lego Mindstorm Discussion     FIRST Tech Challenge     VEX         VEX Robotics Competition         VEX IQ     Televised Robotics     Math and Science         NASA Discussion ChiefDelphi.com Website     CD Forum Support     Extra Discussion

 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:02 AM.

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

 -- English (12 hour) -- English (24 hour) Contact Us - Chief Delphi - Rules - Archive - Top