Decorate-sort-undecorate idiom: Difference between revisions

m
(Added FreeBasic)
Line 156:
FreeBASIC doesn't normally print string lists in "quoted" form though I've added the quotes here to be consistent with the other solutions.
<syntaxhighlight lang="vb">Type map
ax As String
by As Integer
End Type
 
Line 166:
min = i
For j = i + 1 To ub
If array(1,j).by <= array(1,min).by Then min = j
Next j
Swap array(min,1).ax, array(i,1).ax
Swap array(1,min).by, array(1,i).by
Next i
End Sub
Line 179:
' Decorate
For p = lb To ub
e(p,1).ax = a(p)
e(1,p).by = Len(a(p))
Next
Line 189:
Print "[";
For p = lb To ub
Print !"\"" & e(p,1).ax & !"\", ";
Next
Print Chr(8) & Chr(8) & "]"
2,169

edits