Jump to content

Help with Array_multisort


djanim8

Recommended Posts

OK I don't know if I'm tired or what, but I can't figure out this array multisort thing..

 

I have a bunch of records with songs that were requested, selected by DISTINCT and then getting the number of records of each song, then inputing this data:

 

$requestArray[$arNum] = array($songCount, $countRow['title'], $countRow['artist'], $countRow['disc'], $countRow['track'], $countRow['genre']);

 

Then I want to sort it by the genre, and the songCount like this:

 

array_multisort($requestArray[5], SORT_ASC, SORT_STRING, $requestArray[0], SORT_NUMERIC, SORT_DESC);

 

And it won't sort... so what am I missing, what am I doing wrong?

 

btw.. for some reason it it does this on the very first row:

Genre_____________________Artist__Song__Disc____________________Track_______# Reqs

Country - 2000 - Vol. 14______17_____6____Cross Canadian Ragweed___Country______

 

when it should look like this:

Genre______Artist__________________Song__Disc___________________Track____# Reqs

Country____Cross Canadian Ragweed___17___Country - 2000 - Vol. 14___6________1

 

and I have NO idea why, it only does it on the sort...

Link to comment
Share on other sites

will this sort the whole array?

 

Yes.

 

I don't completley understand what was going on in that function LOL

 

usort passes each pair of array elements for comparison ($a and $b) to the function. If $a should sort before $b, returns a number < 0. If a should sort below b, returns a number > 0; If they are equal, return 0.

(www.php.net/usort)

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.