-2

I want to sort an array. My array look like this

    Array ( [bookid] => 16 [book_name] => 22 [created_date] => 16 [hash_key] => 18 )

I want to sort by value like

   Array (  [book_name] => 22 [hash_key] => 18 [created_date] => 16  [bookid] => 16)

if any one know about this please help me.

deepu sankar
  • 4,335
  • 3
  • 26
  • 37
  • "Not working" implies that you've already wrote some code which has a problem. That does not seem to match your actual question. In fact, there isn't even a question. – deceze Aug 06 '14 at 08:47

1 Answers1

0

you can use arsort

<?php
$your_array = array(
                      "bookid" => 16,
                      "book_name" => 22,
                      "created_date" => 16,
                      "hash_key" => 18
                    );  
arsort($your_array);
print_r($your_array);                  
?>

output:

Array
(
    [book_name] => 22
    [hash_key] => 18
    [created_date] => 16
    [bookid] => 16
)

DEMO

Satish Sharma
  • 9,547
  • 6
  • 29
  • 51