<?php
/*
As I found the sort() function normally works as ascending order based on the following priority :
1. NULL
2. Empty
3. Boolean FALSE
4. String
5. Float
6. Int
7. Array
8. Object
Consider the following array:
*/
$a = ['fruit'=> 'apple', 'A' => 10, 20, 5, 2.5, 5=>'A new value', 'last' => 'value', TRUE, NULL, "", FALSE, array(), new StdClass];
sort($a);
var_dump($a);
#The output is:
array(13) {
[0]=>NULL
[1]=> string(0) ""
[2]=>bool(false)
[3]=>string(11) "A new value"
[4]=>string(5) "apple"
[5]=>string(5) "value"
[6]=> float(2.5)
[7]=> int(5)
[8]=>int(10)
[9]=>int(20)
[10]=>array(0) { }
[11]=> bool(true)
[12]=>object(stdClass)#1 (0) {}
}
//Hope it will remove your confusion when you're sorting an array with mix type data.
?>