Jump to content

Sort numbers lexicographically: Difference between revisions

(Added Fōrmulæ solution)
Line 614:
</pre>
 
=={{header|jq}}==
{{works with|jq}}
'''Works with gojq, the Go implementation of jq'''
<lang jq>
def sort_range($a;$b): [range($a;$b) | tostring] | sort | map(tonumber);
 
# Example
# jq's index origin is 0, so ...
sort_range(1;14)</lang>
{{out}}
<pre>
[1,10,11,12,13,2,3,4,5,6,7,8,9]
</pre>
=={{header|Julia}}==
<lang julia>lexorderedsequence(n) = sort(collect(n > 0 ? (1:n) : n:1), lt=(a,b) -> string(a) < string(b))
2,515

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.