Sort disjoint sublist: Difference between revisions

add RPL
No edit summary
(add RPL)
Line 2,963:
<pre>
[7, 0, 5, 4, 3, 2, 1, 6]
</pre>
 
=={{header|RPL}}==
≪ SORT → set
≪ { } 1 set SIZE '''FOR''' j
OVER set j GET GET + '''NEXT'''
SORT SWAP
1 set SIZE '''FOR''' j
set j GET 3 PICK j GET PUT '''NEXT'''
SWAP DROP
≫ ≫ '<span style="color:blue">'''SUBSORT'''</span>' STO
HP-28 models shall use their homemade version of the SORT instruction, or use the one defined in [[Sorting algorithms/Bubble sort#RPL|Sorting algorithms/Bubble sort]]
{ 7 6 5 4 3 2 1 0 } { 6 1 7 } <span style="color:blue">'''SUBSORT'''</span>
{{out}}
<pre>
1: { 7 0 5 4 3 2 1 6 }
</pre>
 
1,151

edits