bug fix for array sort method