Sort stability: Difference between revisions

added sort by rowid to enforce a stable sort
m (→‎{{header|Go}}: update text for current library.)
(added sort by rowid to enforce a stable sort)
Line 330:
 
=={{header|OpenEdge/Progress}}==
The results can be forced to stable by ''additionally'' sorting on the ROWID of the record. If you leave the additional sort out the indexes on the temp-table can influence the result.
{{incorrect|OpenEdge/Progress|This is not enough as a particular sort might give a particular result whilst saying nothing about the stability '''in general'''.}}
The results are stable.
<lang progress>DEFINE TEMP-TABLE tt
FIELD country AS CHAR FORMAT 'x(2)'
FIELD city AS CHAR FORMAT 'x(16)'
.
 
DEFINE VARIABLE cc AS CHARACTER EXTENT 2.
 
CREATE tt. ASSIGN tt.country = 'UK' tt.city = 'London'.
Line 342 ⟶ 343:
CREATE tt. ASSIGN tt.country = 'UK' tt.city = 'Birmingham'.
 
cc[1] = 'by country~n~n'.
FOR EACH tt BY tt.country:
FOR EACH tt DISPLAYBY tt.country BY ROWID( tt.city. ):
cc[1] = cc[1] + tt.country + '~t' + tt.city + '~n'.
END.
 
cc[2] = 'by city~n~n'.
FOR EACH tt BY tt.city:
FOR EACH tt DISPLAYBY tt.countrycity BY ROWID( tt.city. ):
cc[2] = cc[2] + tt.country + '~t' + tt.city + '~n'.
END.</lang>
END.
 
MESSAGE
cc[1] SKIP(1) cc[2]
VIEW-AS ALERT-BOX.</lang>
 
'''Output:'''
<pre>---------------------------
Message
---------------------------
by country
 
UK London
UK Birmingham
US New York
US Birmingham
 
 
by city
 
US Birmingham
UK Birmingham
UK London
US New York
---------------------------
OK
---------------------------</pre>
 
=={{header|Oz}}==
73

edits