Sorting algorithms/Gnome sort: Difference between revisions

Content added Content deleted
(added RPL)
m (→‎{{header|RPL}}: improved code)
 
Line 4,095: Line 4,095:
« 2
« 2
'''WHILE''' h s < '''REPEAT'''
'''WHILE''' h s < '''REPEAT'''
'''IF''' OVER h GETI UNROT GET ≤ '''THEN'''
'''IF''' OVER h DUP 1 + SUB EVAL ≤ '''THEN'''
'h' ▶ 1 +
'h' ▶ 1 +
'''ELSE'''
'''ELSE'''
Line 4,109: Line 4,109:
1: { 0 1 2 3 4 5 6 7 8 9 }
1: { 0 1 2 3 4 5 6 7 8 9 }
</pre>
</pre>
This implementation of gnome sort is 33 times slower than the <code>SORT</code> built-in function on a HP-50g.
This implementation of gnome sort is 30 times slower than the <code>SORT</code> built-in function on a HP-50g.


=={{header|Ruby}}==
=={{header|Ruby}}==