return sorted array