rsnider19 Posted October 9, 2009 Share Posted October 9, 2009 I am working on some software so I hope I can get my problem across without divulging too much about it. Basically, I have an associative array which links a word to an array with some information about the word. How can I sort the associative array based on two pieces of information in the nested array? Say info1 ascending and info2 descending. I kind of found some information for Java, but I can't quite figure out how to port it to php. Link to comment https://forums.phpfreaks.com/topic/177091-sorting-array-based-on-multiple-parameters/ Share on other sites More sharing options...
kickstart Posted October 9, 2009 Share Posted October 9, 2009 Hi You can use usort. It will pass each array member in turn to a function you write, and in your case each array member is itself an array, hence you decide which of the sub arrays are compared in which order to decide which is the larger / smaller. All the best Keith Link to comment https://forums.phpfreaks.com/topic/177091-sorting-array-based-on-multiple-parameters/#findComment-933727 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.