perezf Posted February 22, 2009 Share Posted February 22, 2009 Does anyone know how to fix the problem with php sorting numbers for some reason when i do a uasort and i have the numbers 1,6,9,10 it sorts it like this 1,10,6,9 How can i fix that? Quote Link to comment https://forums.phpfreaks.com/topic/146315-problem-sorting-numbers/ Share on other sites More sharing options...
Cosizzle Posted February 22, 2009 Share Posted February 22, 2009 can you post your code including your array? Quote Link to comment https://forums.phpfreaks.com/topic/146315-problem-sorting-numbers/#findComment-768165 Share on other sites More sharing options...
.josh Posted February 22, 2009 Share Posted February 22, 2009 uasort sorts things based on a user defined comparison. It's not php's fault the numbers don't sort the way you want them. It's yours. Post your code, post an example list of stuff to sort, and example of what you want the result to look like and why it's supposed to be sorted like that. Quote Link to comment https://forums.phpfreaks.com/topic/146315-problem-sorting-numbers/#findComment-768167 Share on other sites More sharing options...
Philip Posted February 22, 2009 Share Posted February 22, 2009 Take a look at natsort() It'll sort numbers by what you think is correct, 1,3,5,20,41 instead of 1,20,3,41,5 Quote Link to comment https://forums.phpfreaks.com/topic/146315-problem-sorting-numbers/#findComment-768206 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.