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. Link to comment https://forums.phpfreaks.com/topic/129650-help-sorting-array/ 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. Link to comment https://forums.phpfreaks.com/topic/129650-help-sorting-array/#findComment-672175 Share on other sites More sharing options...
TheBiff Posted October 22, 2008 Author Share Posted October 22, 2008 They output 1. Link to comment https://forums.phpfreaks.com/topic/129650-help-sorting-array/#findComment-672183 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. Link to comment https://forums.phpfreaks.com/topic/129650-help-sorting-array/#findComment-672186 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! Link to comment https://forums.phpfreaks.com/topic/129650-help-sorting-array/#findComment-672202 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.