Does anyone know what the function is to perform a natural order sort using the usort function in PHP on an object.
Lets say the object ($obj->Rate)has a range of values in
$obj->10
$obj->1
$obj->2
$obj->20
$obj->22
What is I am trying to get the sort function to return
$obj->22
$obj->20
$obj->10
$obj->2
$obj->1
As my current standard sort function
function MySort($a, $b)
{
if ($a->Rate == $b->Rate)
{
return 0;
}
return ($a->Rate < $b->Rate) ? -1 : 1;
}
is returning
$obj->1
$obj->10
$obj->2
$obj->20
$obj->22
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…