DssTrainer Posted August 13, 2008 Share Posted August 13, 2008 Its an odd question, i think.. but here is the situation: I have an array of data that I pull from the database. I have to extract it using a different method than sort_order, but after I get it, I want to sort it by sort order $category_data[] = array( 'name' => $result['name'], 'href' => $url->href('category', false, array('path' => $result['path'])), 'class' => $class, 'xsort' => $result['sort_order'] ); This results in $category_data : array = 0: array = name: string = "Electronics" href: string = "http://localhost/category/path/1" class: string = "cat_lvl_0" xsort: string = "1" 1: array = name: string = "CellPhones" href: string = "http://localhost/category/path/22" class: string = "cat_lvl_0" xsort: string = "0" Now, I want to sort it by the "xsort" value. As you can see Electronics has a sort of 1 but CellPhones has a sort of 0. So I want Cellphones first. How can I sort that? Link to comment https://forums.phpfreaks.com/topic/119520-possible-to-sort-array-by-sublevel-value/ Share on other sites More sharing options...
genericnumber1 Posted August 13, 2008 Share Posted August 13, 2008 Look into usort() http://us3.php.net/usort Link to comment https://forums.phpfreaks.com/topic/119520-possible-to-sort-array-by-sublevel-value/#findComment-615740 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.