Possible Duplicate:
How can I sort arrays in php by a custom alphabet?
For example, i have six words:
banana, apple, love, zasca, japanese, car
Is there a way to sort in alphabetic order, using this custom order: “j, c, z, l, a”?
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.
Here’s some rough code to get you started:
Basically, it looks at the first letter of each word in the data array, the checks its position in the
$sortOrderarray. Letters that aren’t in$sortOrderget put onto the end in the order appear.Right off the bat, this is going to break if
$sortOrderhas more than 100,000 items in it. There are probably other holes too but I figure it’s a decent enough example of howusort()works.