Closed Thread
Results 1 to 6 of 6

Thread: Sorting Arrays

  1. #1
    falco85 is offline Programmer
    Join Date
    Apr 2006
    Posts
    105
    Rep Power
    0

    Sorting Arrays

    Is there a way to sort a multi-dimensional array?

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Jul 2006
    Posts
    16,486
    Blog Entries
    75
    Rep Power
    143
    Yes. Now, what are your criteria for the array being "sorted"?
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  4. #3
    falco85 is offline Programmer
    Join Date
    Apr 2006
    Posts
    105
    Rep Power
    0
    Well I have an array that looks like this:

    array[0] = "data1|data2|data3|data4";
    array[1] = "data1|data2|data3|data4";

    I need the array sorted by data3. The only way I can think of doing it is by cycling through the array - exploding it and then adding the data to another array. Is that right?

  5. #4
    Join Date
    Jul 2006
    Posts
    16,486
    Blog Entries
    75
    Rep Power
    143
    It depends a little bit on whether you need to sort data1, data2, data4 in parallel with data3. If you need to sort data3 and not touch the others, I'd just pass data3 into your sort algorithm and be done.

    Basicly, you need to find a "key" that you can sort linearly, and work everything off that as necessary.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  6. #5
    Crane's Avatar
    Crane is offline Programming Expert
    Join Date
    Nov 2005
    Posts
    398
    Rep Power
    25
    Did you ever figure this one out? I'd like to see the code results from it.

  7. #6
    Join Date
    Jul 2006
    Posts
    16,486
    Blog Entries
    75
    Rep Power
    143
    The problem is that I don't know PHP. And I wasn't clear what exactly needs to get sorted.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Sorting Values from Arrays
    By An Alien in forum Java Help
    Replies: 13
    Last Post: 03-06-2011, 06:36 PM
  2. Sorting Arrays
    By chili5 in forum Java Tutorials
    Replies: 11
    Last Post: 02-07-2010, 12:45 PM
  3. Need help sorting 2 arrays.
    By posto2012 in forum C and C++
    Replies: 3
    Last Post: 10-11-2009, 04:46 PM
  4. Simple Arrays Sorting Help?
    By Puff in forum C and C++
    Replies: 17
    Last Post: 08-15-2009, 12:23 PM
  5. Help regarding the sorting of arrays with flags!
    By Yuriy M in forum C and C++
    Replies: 3
    Last Post: 10-12-2007, 08:30 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts