Sort stability: Difference between revisions

jq
m (→‎{{header|Factor}}: Add Fortran's deficiency.)
(jq)
Line 366:
<pre>UK,London,US,New York,US,Birmingham,UK,Birmingham
UK,Birmingham,US,Birmingham,UK,London,US,New York</pre>
 
=={{header|jq}}==
As of January 18, 2016 (Commit SHA 7835a72), the builtin sorting filters (notably sort/0 and sort_by/1) are stable; prior to that, stability was platform-dependent. This means that stability is NOT guaranteed in jq 1.5 or earlier. In the following, a version of jq with sorting stability has been used.
 
<lang jq>[["UK", "London"],
["US", "New York"],
["US", "Birmingham"],
["UK", "Birmingham"]]
| sort_by(.[1])</lang>
 
Invocation:
<pre>$ jq -c -n -f rc-sort-stability.jq</pre>
 
{{out}}
<pre>[["US","Birmingham"],["UK","Birmingham"],["UK","London"],["US","New York"]]</pre>
 
=={{header|Julia}}==
2,456

edits