3 ms·
Golf time! in js: require('fs').readFileSync('list.txt').split('\n').sort(function(a,b){return b.length-a.length});
by binarymax 13y ago
Golf time! in js:
require('fs').readFileSync('list.txt').split('\n').sort(function(a,b){return b.length-a.length});
- gamegoblin 13y agoPython: sorted(open("list.text").readlines(),key=len) Haskell: (sortBy (comparing length).lines.readFile) "list.txt"
- jloughry 13y agoEliminate the temporary file: sed -e "s/./x/g" < list.txt | paste - list.txt | sort | cut -f 2
- jloughry 13y agoWe can eliminate the paste by using sed's hold buffer, but it costs another regexp to get rid of the spurious newline: sed -e "h;s/./x/g;G;s/\n/\t/g" list.txt | sort | cut -f2