Skip to content

Instantly share code, notes, and snippets.

@ormaaj
Created Oct 26, 2012
Embed
What would you like to do?
Ultra-slow mtime insertion sort
function mtimes {
typeset x=
typeset -i n=0
for x; do
n=0
if [[ -d $x ]]; then
mtimes "$x"/*
else
while [[ ${arr[n]+$x} -ot ${arr[n]} ]]; do
((n++))
done
arr=("${arr[@]:0:n}" "$x" "${arr[@]:n}")
fi
done
}
typeset -a arr
${1:+mtimes "$@"}
stat -c %y\ %n "${arr[@]}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment