Sorting algorithms/Gnome sort: Difference between revisions

Content added Content deleted
m (→‎version 1: used exact comparisons for literal strings.)
(→‎version 2: corrected program and output)
Line 1,717:
<lang rexx>/* REXX ---------------------------------------------------------------
* 28.06.2014 Walter Pachl cf ooRexx version 2
* only style changes (reformatting) and adapt for ooRexx compatibility
* NOTE that leading blanks are ignored in the comparison (' Justice')
* unless strict comparison is used (i.e., 'If x.km<<=x.k Then')
* 30.06.2014 WP added the missing else clause
*--------------------------------------------------------------------*/
/* generate the array elements. */
Line 1,741 ⟶ 1,742:
If k==1 Then
k=j
Else
j=j-1
End
End
Line 1,757 ⟶ 1,760:
Say 'element' right(i,2) x.i
End
Return</lang>
</lang>
'''output'''
<pre>before sort
Line 1,774 ⟶ 1,778:
element 3 Charity [Love]
element 4 Faith
element 5 HopeFortitude
element 6 FortitudeHope
element 7 Justice
element 8 Prudence