Added sort_array function