Skip to content

Instantly share code, notes, and snippets.

@GideonPARANOID
Last active August 29, 2015 14:13
Show Gist options
  • Save GideonPARANOID/a30f24db6c3bed202329 to your computer and use it in GitHub Desktop.
Save GideonPARANOID/a30f24db6c3bed202329 to your computer and use it in GitHub Desktop.
Ordering an input string in descending word length - 161 characters
#!/bin/bash
a=(${1/// });for l in `seq 0 ${#a[@]}`;do for((i=l;i>0;i--));do j=$((i-1));[ ${#a[i]} -gt ${#a[j]} ]&&eval "a[$j]=${a[$i]};a[$i]=${a[$j]}";done;done;echo ${a[*]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment