-2

I have this array :

Array
(
  [26] => Array
    (
        [total_auctions] => 1
        [total_price] => 0
    )

  [24] => Array
    (
        [total_auctions] => 0
        [total_price] => 0
    )

  [25] => Array
    (
        [total_auctions] => 0
        [total_price] => 0
    )
)

I want to sort this array to be :

Array
(
[24] => Array
(
    [total_auctions] => 0
    [total_price] => 0
)
[25] => Array
(
    [total_auctions] => 0
    [total_price] => 0
)

[26] => Array
(
    [total_auctions] => 1
    [total_price] => 0
 )
)

I tried with array_multisort but not work. Can you help me please ? Thx in advance. I don't understand where is the problem, normally should work

Harea Costicla
  • 797
  • 3
  • 9
  • 20

1 Answers1

-1

Just use ksort() to sort any array keys

<?php 
$arr = array(
  '26' => array('total_auctions' => 1,'total_price' => 0),
  '24' => array('total_auctions' => 0,'total_price' => 0),
  '25' => array('total_auctions' => 0,'total_price' => 0)
  );
ksort($arr);
print '<pre>';print_r($arr);
exit;
?>
Dhara Parmar
  • 8,021
  • 1
  • 16
  • 27