Page 1 of 1

Sorting multi dimensional array with a certain key

Posted: 18 Jul 2011, 16:17
by DarkRanger
I have the following:

Code: Select all

$resultArray[$c]['id'];
$resultArray[$c]['filename'];
$resultArray[$c]['keywords'];
$resultArray[$c]['matchPercentage'];
How do I sort this array by $resultArray[$c]['matchPercentage'] from high to low?

Re: Sorting multi dimensional array with a certain key

Posted: 18 Jul 2011, 16:27
by D3PART3D
Wow, awesome thread title.

Re: Sorting multi dimensional array with a certain key

Posted: 18 Jul 2011, 16:31
by DarkRanger
What should I have named it? :P

Re: Sorting multi dimensional array with a certain key

Posted: 18 Jul 2011, 16:38
by D3PART3D
No, I mean Star Trek awesome.

Re: Sorting multi dimensional array with a certain key

Posted: 20 Jul 2011, 13:06
by Bladerunner
DarkRanger wrote:I have the following:

Code: Select all

$resultArray[$c]['id'];
$resultArray[$c]['filename'];
$resultArray[$c]['keywords'];
$resultArray[$c]['matchPercentage'];
How do I sort this array by $resultArray[$c]['matchPercentage'] from high to low?
Are you looking for something along the lines of Array.Sort ( :P ) or are you actually interested in implementing an algorithm like Bubble-, Selection-, Insertion-, or Quicksort?

Re: Sorting multi dimensional array with a certain key

Posted: 21 Jul 2011, 12:09
by DarkRanger
Just want something basic. So along the lines of array.sort will be fine!