Decorate-sort-undecorate idiom: Difference between revisions

m
julia example
m (minor correction)
m (julia example)
Line 71:
 
[[File:Fōrmulæ - Decorate-sort-undecorate idiom 05.png]]
 
 
=={{header|Julia}}==
<pre>
julia> schwartzian(arr, f) = map(t -> t[1], sort!(map(v -> (v, f(v)), arr), by = t -> t[2]))
schwartzian (generic function with 1 method)
 
julia> schwartzian(["Rosetta", "Code", "is", "a", "programming", "chrestomathy", "site"], length)
7-element Vector{String}:
"a"
"is"
"Code"
"site"
"Rosetta"
"programming"
"chrestomathy"
</pre>
4,108

edits