Fixed build_sort_array