ToSortedArray method