So, I have a file array list in a bash shell, and I want to sort all the files in the array by the date modified, starting with the oldest being the first one in the array. However, I don't want to sort and modify the original array, and instead want to have the sorted result be in a different array. I saw this thread in which I tried the following command, although I modified it since the array was a variable and not a file.
new_array=( $(ls -t $(printf '%s\n' "${array_list[@]}")) )
However, the array is so big that ls reports the argument list is "too long"
Is there another way I can sort the main array by the modified date, starting with the oldest file at the beginning, and save the results to a different array?