fix a small bug for using Array.sort() wrongly