php sort array without custom function -


here extract of test code , data:-

//update array  $civs[1][1]="1"; $civs[1][2]="inca"; $civs[2][1]="2"; $civs[2][2]="india";  //sort array  array_multisort($civs[0][2], sort_desc, sort_string,             $civs[0][1], sort_numeric, sort_desc); 

output:-

warning: array_multisort(): argument #1 expected array or sort flag in ~/test.php on line 3

array(3) { [1]=> array(2) { [1]=> string(1) "1" [2]=> string(4) "inca" } [2]=> array(2) { [1]=> string(1) "2" [2]=> string(5) "india" } [0]=> array(2) { [2]=> null [1]=> null } } 

problem statement depending on user selects need sort array in php either on 1st (numeric) or 2nd (alphanumeric) element of 2nd part of array can't see how that, various php sorts don't seem allow tell sorted on, have tried above code . php manual uksort says "if array wish sort needs sorted non-trivial criteria," numeric trivial gets!

i've been looking @ couple of hours , sure must missing can see have write custom function surely php knows how simple sorts based on numeric or text values?

main question found this:- how can sort arrays , data in php? , spent fair bit of time browsing through http://php.net/manual/en/array.sorting.php.

apologies if have missed obvious.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -