TheBiff Posted October 22, 2008 Share Posted October 22, 2008 I need help sorting an array. Here is an example of what it looks like: $data[w-99-893] = array('text',array('a'=>'12','b'=>'12'),'M'); $data[w-68-e02] = array('text',array('a'=>'16','b'=>'14'),'M'); $data[w-95-102] = array('text',array('a'=>'10','b'=>'11'),'M'); I need to sort by that first key (w-99-893,w-68-e02,w-95-102). All of the standard php functions don't seem to do it. I keep getting 1 as an output. Any ideas? Thanks. Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted October 22, 2008 Share Posted October 22, 2008 Something like ksort or krsort should be what you need. Quote Link to comment Share on other sites More sharing options...
TheBiff Posted October 22, 2008 Author Share Posted October 22, 2008 They output 1. Quote Link to comment Share on other sites More sharing options...
Orio Posted October 22, 2008 Share Posted October 22, 2008 But the array will be sorted (it's passed by reference, not by value). The 1 indicates boolean true- the sort was successful. Orio. Quote Link to comment Share on other sites More sharing options...
TheBiff Posted October 22, 2008 Author Share Posted October 22, 2008 Great. Thanks. Instead of doing ksort($data) i was doing $data=ksort($data). It's been a long day. Thanks! Quote Link to comment 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.