[eluser]Ravi Raj[/eluser]
I have introduced codeigniter library for associative array sorting on the basis of array's column. see following lines of code to know How to use library.
Code:
$this->load->library('MY_sort_associative_array');
$sorter = new MY_sort_associative_array;
// some starting data
$start_data = array(
array('first_name' => 'John', 'last_name' => 'Smith', 'age' => 10),
array('first_name' => 'Joe', 'last_name' => 'Smith', 'age' => 11),
array('first_name' => 'Jake', 'last_name' => 'Xample', 'age' => 9),
);
// sort by last_name, then first_name
print_r($sorter->sort_associative_array($start_data, 'last_name', 'first_name'));
// sort by first_name, then last_name
print_r($sorter->sort_associative_array($start_data, 'first_name', 'last_name'));
// sort by last_name, then first_name (backwards)
$sorter->backwards = true;
print_r($sorter->sort_associative_array($start_data, 'last_name', 'first_name'));
// sort numerically by age
$sorter->numeric = true;
print_r($sorter->sort_associative_array($start_data, 'age'));
if anybody found any issue then please let me know.