1

I'm really sorry if this has been answered before, but here is my problem
I have this:

 array (size=256)
      0 =>
            array (size=2)<br>
                0 => string 'name_a'
                1 => string '2175'
      1 =>
            array (size=2)
                0 => string 'name_d'
                1 => string '1'
      2 =><
            array (size=2)
                0 => string 'name_c'
                1 => string '715'
      3 =>
            array (size=2)
                0 => string 'name_b'
                1 => string '5'

And I want to be able to sort it by the number from most to least or/and name and if I add more info for each name such as time value. Its a huge array(over 400 I think) and I need to display it one by one, from top to bottom. If anyone have any ideas, I'd love to hear them!

1

1 Answer 1

0

Use usort like so:

function myComp($a, $b) {
    if($a[1] == $b[1]) {
        return 0;
    }

    return ($a[1] > $b[1]) ? -1 : 1;
}

usort($myArray, 'myComp');
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.