-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
  • 759
  • 3
  • 8
  • 18

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
  • 7,791
  • 1
  • 14
  • 25