tobeyt23 Posted March 27, 2009 Share Posted March 27, 2009 I have an array with a key shortname. I need to sort the array by sortname in a specific order how can I accomplish this? for Example I need shortname order like this (What, Bob, Jake, How). Quote Link to comment https://forums.phpfreaks.com/topic/151389-array-sorting/ Share on other sites More sharing options...
Jagarm Posted March 27, 2009 Share Posted March 27, 2009 Maybe this function will help you http://ca.php.net/manual/en/function.sort.php , it sort arrays Quote Link to comment https://forums.phpfreaks.com/topic/151389-array-sorting/#findComment-795144 Share on other sites More sharing options...
Maq Posted March 27, 2009 Share Posted March 27, 2009 I have an array with a key shortname. I need to sort the array by sortname in a specific order how can I accomplish this? for Example I need shortname order like this (What, Bob, Jake, How). I still don't understand what the "specific order" is? I don't see any type of sort in: (What, Bob, Jake, How) Quote Link to comment https://forums.phpfreaks.com/topic/151389-array-sorting/#findComment-795148 Share on other sites More sharing options...
steelaz Posted March 27, 2009 Share Posted March 27, 2009 If your array looks like this: $array = array('What', 'Bob', 'Jake', 'How'); you can sort it using sort() function: sort($array); Quote Link to comment https://forums.phpfreaks.com/topic/151389-array-sorting/#findComment-795149 Share on other sites More sharing options...
tobeyt23 Posted March 27, 2009 Author Share Posted March 27, 2009 Here is the array, I want the shortname not to be alpha but in an order i set such as b,a,c or c,a,b or b,c,a Array ( [0] => Array ( [orderId] => 269 [shortName] => a ) [1] => Array ( [orderId] => 269 [shortName] => b ) [2] => Array ( [orderId] => 269 [shortName] => c ) ) Quote Link to comment https://forums.phpfreaks.com/topic/151389-array-sorting/#findComment-795165 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.