sorting doesn't sort?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Håvard Olerud Eriksen

    #1

    sorting doesn't sort?

    I've got an array of arrays that I need to sort on preferably one of the
    indices of the nested array, keeping the order of the outside array. The
    structure is like this:

    array([i] => array(key["name"] => data)
    and what I need to do is to sort the nested array alphabetically according
    to key["name"].
    I can either use the name property of the nested array as index for the
    outside array (then I need to keep the relationship between the outside
    array and the nested array, or use a numeric index thus making the
    relationship between the outside and nested array irrellevant.) What I need
    to do in any case is to sort the nested array. I've tried using
    arsort($array, SORT_STRING) but for some reason this doesn't sort the array
    the way that I expected.

    Can anyone help me out?

    A var_dump of one element of the outside array looks like this:
    array(2)
    { [1]=> array(2)
    { ["id"]=> string(1) "1" ["name"]=> string(6) "JustforSho w" }
    { [2]=> array(2)
    { ["id"]=> string(1) "1" ["name"]=> string(6) "Testing" }

    etc.


Working...