HI i want to sort an array of objects , it is in the form of array which has objects and each objects has key,value , i want to sort the objects based on value, the problem is t
Of course you can use usort, you simply need to pre-process the values inside the usort compare function prior to comparing. I'm assuming you want to remove the spaces, treat empty numbers as zeros, and ignore leading zeros. Assuming all that your custom compare function might look something like this:
function my_sort($obja, $objb)
{
$a = (int)(str_replace(" ", "", $obja->value));
$b = (int)(str_replace(" ", "", $objb->value));
if ($a == $b) return 0;
return ($a > $b) ? -1 : 1;
}