I am not using an associative array. I’m using 1d array like this,
array("1,a","5,b","2,c","8,d","6,f");
How can I sort this array?
The result should be,
array("1,a","2,c","5,b","6,f","8,d");
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I’m going to go ahead and assume you want to sort by the number part first, sorting numerically, and then have a secondary lexographic (string) sort on the bit after the comma. That way a value like “11,a” will end up after “2,a” – if you just do a default sort “11,a” will end up before “2,a”. So:
Result: