You can use the following function to get the newest file in a directory:
newest_in()
{
local newest=$1
for f;do [[ $f -nt $newest ]] && newest="$f"; done;
printf '%s\n' "$newest"
}
Give it a different set of files by exculding the newest file after each iteration.
Tip: If you hold the initial set of files in an array called "${files[@]}", then save the index of the newest file found, and unset 'files[index]'
before the next iteration.
Usage: newest_in [set of files/directories]
Sample output:
[rany$] newest_in ./*
foo.txt
[rany$]