SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2010
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Wink array_multisort but with empty values last

    Hello,

    I have 4 arrays that I sort with:

    array_multisort($arrays["first"],$arrays["second"],$arrays["third"], $arrays["'last"]);

    The first array has empty elements and I want to put them at the end of the list. Multisort puts them at the beginning, is there a simple way to do that?

    Thanks

  2. #2
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Can you post some example data which demonstrates your point?

    Before and after samples would be nice...

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2010
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sure!

    http://codepad.org/V6TjCsS5

    The first container array in the result is the one that has to be sorted.
    The second one is the sorted one.
    But, as you can see, in $arrays[0][0], there's the empty value that I want last with the other values associated with it ("two" and "option2");


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
  •