Last active
August 29, 2015 14:13
-
-
Save GideonPARANOID/a30f24db6c3bed202329 to your computer and use it in GitHub Desktop.
Ordering an input string in descending word length - 161 characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode 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