I believe you should use natsort () . This happens when you try to sort numbers that are processed as a string. Here is an example:
$a=array('1a','2a','3a','10a','15a'); rsort($a); echo implode(',',$a);
But you expect the output as follows:
15a,10a,3a,2a,1a
To do this, use natsort and array_reverse () :
$a=array('1a','2a','3a','10a','15a'); natsort($a); $a=array_reverse($a); echo implode(',',$a);
source share