Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Feb 2004
    Location
    Switzerland
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Sorting a 2 dimentional array

    I have a 2 dimentional array called $country_list with "url" and "name" as keys:

    Ie:

    country_list[0]["url"] = "xxx"
    country_list[0]["name"] = "aaa"

    country_list[1]["url"] = "yyy"
    country_list[1]["name"] = "bbb"

    country_list[2]["url"] = "zzz"
    country_list[2]["name"] = "ccc"

    How do I sort the array by the name key?

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #3
    New Coder
    Join Date
    Feb 2004
    Location
    Switzerland
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks, but after more analysis, I discovered the array actually looks like this: (slighty more complicated).

    Array ( [0] => stdClass Object ( [url_trademap] => http://www.trademap.net/benin/connection.htm [country] => Benin ) [1] => stdClass Object ( [url_trademap] => http://www.trademap.net/bolivia/conexion.htm [country] => Bolivia ) [2] => stdClass Object ( [url_trademap] => http://www.trademap.net/burkina/connection.htm [country] => Burkina Faso ) [3] => stdClass Object ( [url_trademap] => http://www.trademap.net/prochile/conexion.htm [country] => Chile ) [4] => stdClass Object ( [url_trademap] => http://www.trademap.net/china/login.htm [country] => China )

    etc. etc.

    I tried multisort, but that didn't work. I actually need to specify the "country" key (inside the object) somewhere or somehow.


  •  

    Posting Permissions

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