desithugg Posted May 15, 2007 Share Posted May 15, 2007 Umm I want to sort an array twice. First alphabetically than numerically. I tried sort($arry); But that just sorts it numerically. given me the output HM02,HM03,HM04,HM05,TM01,TM02,TM04,TM05,TM07,TM11,TM12,TM13,TM14,TM15,TM16,TM17,TM18,TM19,TM23,TM24,TM25,TM26,TM27,TM28,TM29,TM30,TM35,TM36,TM37,TM38,TM39,TM40,TM41,TM42,TM43,TM45,TM46,TM47,TM48,TM49,HM01,TM03,TM06,TM08,TM09,TM10,TM20,TM21,TM22,TM31,TM32,TM33,TM34,TM44,TM50 So as you can see there's mixing between HM and TM I want them both seperate. Any body know how i can do that? Link to comment https://forums.phpfreaks.com/topic/51510-solved-php-array-sort/ Share on other sites More sharing options...
MadTechie Posted May 15, 2007 Share Posted May 15, 2007 what about natsort Link to comment https://forums.phpfreaks.com/topic/51510-solved-php-array-sort/#findComment-253669 Share on other sites More sharing options...
Psycho Posted May 15, 2007 Share Posted May 15, 2007 Can you show some more of the code (e.g. creating the array, sorting and printing). What you are showing doesn't make sense. You should not be getting the results you state. I took the values you have above, mixed them up, applied sort to the array, and I am getting expected results. Link to comment https://forums.phpfreaks.com/topic/51510-solved-php-array-sort/#findComment-253681 Share on other sites More sharing options...
desithugg Posted May 15, 2007 Author Share Posted May 15, 2007 woops my fault. I was wondering why sort() didn't work it was because I had two arrays and I didn't join them. Sorry about that. Link to comment https://forums.phpfreaks.com/topic/51510-solved-php-array-sort/#findComment-253683 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.