Skip to content

Instantly share code, notes, and snippets.

@ormaaj
Created October 26, 2012 22:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ormaaj/3961853 to your computer and use it in GitHub Desktop.
Save ormaaj/3961853 to your computer and use it in GitHub Desktop.
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