Sort stability: Difference between revisions
m
→{{header|Phix}}: inlined and therefore removed all the dopey "2nd sort depends on 1st" nonsense.
m (→{{header|Phix}}: syntax coloured, simplified a bit, and actually sort on the second column as per task description) |
m (→{{header|Phix}}: inlined and therefore removed all the dopey "2nd sort depends on 1st" nonsense.) |
||
Line 1,361:
<span style="color: #008080;">return</span> <span style="color: #7060A8;">compare</span><span style="color: #0000FF;">(</span><span style="color: #000000;">a</span><span style="color: #0000FF;">[</span><span style="color: #000000;">2</span><span style="color: #0000FF;">],</span><span style="color: #000000;">b</span><span style="color: #0000FF;">[</span><span style="color: #000000;">2</span><span style="color: #0000FF;">])</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
<span style="color: #
<span style="color: #000080;font-style:italic;">-----------------------
Line 1,387 ⟶ 1,386:
</pre>
Commenting out the c=0 fixup in tag_cmp makes it unstable, or rather probably stable wrt the shuffle, and sometimes shows the first two lines flipped, whereas the active line guarantees original (pre-shuffle) ordering, even if an unstable underlying sort method were used.
=={{header|PHP}}==
|