Skip to content

Instantly share code, notes, and snippets.

@dnlcorrea
Created September 2, 2017 17:20
Show Gist options
  • Save dnlcorrea/9fef2b29e983930e48b1c539e4220116 to your computer and use it in GitHub Desktop.
Save dnlcorrea/9fef2b29e983930e48b1c539e4220116 to your computer and use it in GitHub Desktop.
Sort region by character length using awk in an Emacs buffer.
(defun awk-sort (&optional b e)
"Sort region by character length using awk."
(interactive "r")
(shell-command-on-region b e "awk '{ print length(), $0 | \"sort -n | cut -d\\\\ -f2-\" }'" (current-buffer) t)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment