177
votes
Sort a list and write some English!
GolfScript
Dear Boss Man.
It came to my attention that my keyboard needs replacement; the keys required to write the
symbols ~ $ ` . and } are not functioning properly.
It's very difficult to work ...
122
votes
Sort a list and write some English!
PHP
Defines a function called item that will sort an array that you pass it.
...
75
votes
71
votes
65
votes
Sort a list and write some English!
NetLogo
To Manager [IT]
Let Sue sort it; then
show Sue the end to the end
With indentation and capitalization changes, the code becomes clear(er). This defines a ...
63
votes
Sort a list and write some English!
C
Input as space-separated list through STDIN, output as space-separated list through STDOUT.
...
57
votes
Accepted
Vertically collapse text
Pyth, 10 bytes
jb_.T.T_.z
Try it online in the Pyth Compiler/Executor.
Idea
We can achieve the desired output by applying four simple transformations:
Reverse ...
50
votes
Accepted
43
votes
Accepted
Lossy Sorting (Implement Dropsort)
APL, 9 bytes
⊢(/⍨)⊢=⌈\
This is a monadic function train with diagram:
┌─┼───┐
⊢ ⍨ ┌─┼─┐
┌─┘ ⊢ = \
/ ┌─┘
⌈
The ...
41
votes
Sort the months of the year
Jelly, 19 bytes
11ị“bMAanlseovc”iµÞ
This is a monadic link that takes a list as argument and sorts it. Try it online!
Background
Jelly uses modular, 1-based ...
39
votes
Vertically collapse text
Haskell, 62 bytes
import Data.List
p=reverse;o=transpose
f=unlines.p.o.o.p.lines
I'm very mature.
38
votes
Output numbers up to 2^n-1, "sorted"
Python, 53 bytes
f=lambda n,i=1:n*[f]and[i]+f(n-1,2*i)+i%2*f(n-1,i-~i)
Try it online!
The recursive function generates the sorted list as a pre-order walk down ...
36
votes
Xorting an array
Pyth, 40 36 31 30 bytes
Ju.|G^2slHxMf>FT.:Q2Z|tSIxRJQJ
Try it online: Demonstration or Test Suite
Each of the big test-cases finishes in a couple of seconds. ...
32
votes
Accepted
26
votes
Accepted
Count My Change
Japt, 5 3 bytes
ñg9
Test it online!
Explanation
I, too, have added a sorting function to my language in the last few weeks :-) ...
25
votes
Sort a list and write some English!
Python 2 & 3
Unfortunately, the employees of today just can't stop using hashtags all over the place...
...
25
votes
Sign that word!
C (with x86), 61 bytes
s[];main(){qsort(s,read(0,s,99),1,"YXZQQQ\x8a\x00*\x02\x0f\xbe\xc0\xc3");puts(s);}
That string contains raw bytes, not actual ...
24
votes
Accepted
Sort the climbing grades
Python 2, 58 54 bytes
lambda x:sorted(x,key=lambda y,B10=0:eval(y[1:]+'10'))
Try it online!
How it works
...
24
votes
DropSort it like it's hot
Haskell, 67 59 58 bytes
(q:r)!x|x<last q=q:r!x|1<2=(q++[x]):r
_!x=[[x]]
foldl(!)[]
Explanation: Given a list of lists (that are already sorted) and a value ...
23
votes
Sort a list and write some English!
Dogescript
It's basically English, right?
shh oooot! my keyybr oad is brokn. i ne ed neew 1.
such fixs much keys
keys dose sort
wow keys
translates to:
...
23
votes
Accepted
Sort an Integer List
05AB1E, 2 bytes
Code:
ϧ
Same algorithm as the Jelly answer. Computes all permutations of the input and pops out the smallest one.
Try it online!
A more efficient ...
23
votes
Accepted
Interleave strings
Jelly, 1 byte
Z
Try it online!
The “transpose” built-in will do exactly this to a list of strings.
23
votes
Enumerate each series of identical numbers in-place
JavaScript (ES6), 26 bytes
1-indexed.
a=>a.map(o=x=>o[x]=-~o[x])
Try it online!
Commented
...
21
votes
21
votes
Book Stack Sort
Python, 113
P=[]
for n in sorted(input())[::-1]:
for p in P:
if p[-1][1]>=n[1]:p+=[n];break
else:P+=[[n]]
print sum(P,[])
After sorting the list of books ...
21
votes
Lossy Sorting (Implement Dropsort)
J, 10 9 bytes
#~(=>./\)
Working version of my CJam idea (in fewer bytes). E.g.:
...
21
votes
Ordering a list
APL, 2 bytes
⍋⍋
The “grade up” built-in, applied twice. Works if indexing starts at 0, which isn’t the default for all flavors of APL. Try it here!
Why does ...
21
votes
Sort digits by their first occurrence in pi
Python 3, 40 39 bytes
1 byte thanks to Jonathan Allan.
lambda s:sorted(s,key="145926870".find)
Try it online!
20
votes
20
votes
Sign that word!
Stuck, 4 bytes
sc$d
This language was documented on the wiki just yesterday! Mmm, fresh esolangs.
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
sorting × 201code-golf × 168
array × 51
string × 36
number × 18
code-challenge × 18
sequence × 10
permutations × 10
integer × 8
restricted-complexity × 8
math × 6
popularity-contest × 5
random × 5
optimization × 5
natural-language × 5
ascii-art × 4
date × 4
matrix × 4
fastest-code × 4
path-finding × 4
stack × 4
arithmetic × 3
restricted-source × 3
combinatorics × 3
graph-theory × 3