Array Sorting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi All,

I've got an array which has the following properties:

$file_array[$filename] = array ("Date" => $Date, "size" => $size,
"permissions" => $permissions);

I can quite happily sort the array by filename (using natksort and
natkrsort), which I found on the php manual - and for reference have
included as a PS!!!!

What I'm not sure about doing is sorting by say Size or Date?

I've again had a look through the php manual but I'm not sure how to sort by
a property...

Can anyone point me in a direction?

Cheers
Nunners

PS.... as promised!

function natksort(&$aToBeSorted) {
	$aResult = array();
	$aKeys = array_keys($aToBeSorted);
	natcasesort($aKeys);
	foreach ($aKeys as $sKey) {
		$aResult[$sKey] = $aToBeSorted[$sKey];
	}
	$aToBeSorted = $aResult;
	return True;
}
		
function natkrsort(&$aToBeSorted) {
	$aResult = array();
	$aKeys = array_keys($aToBeSorted);
	$aKeys = array_reverse(natcasesort($aKeys));
	foreach ($aKeys as $sKey) {
		$aResult[$sKey] = $aToBeSorted[$sKey];
	}
	$aToBeSorted = $aResult;
	return True;
}

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux