Sort the letters of string in alphabetical order: Difference between revisions

m (Undo revision 345366 by DANILIN (talk) since "using static System.Console;" is being used, the "Console." in "Console.Write..." is redundant.)
Line 987:
</pre>
 
=={{header|VBScript}}==
VBScript can't index a string so first we convert the string to an array of chars, then use join to get back a string
<lang vb>
sub bubble(arr)
n = UBound(arr)
Do
nn = -1
For j = 0 to n - 1
If arr(j) > arr(j + 1) Then
temp= arr(j):arr(j)=arr(j+1):arr(j+1)=temp
nn = j
End If
Next
n = nn
Loop Until nn = -1
end sub
 
 
s="The quick brown fox jumps over the lazy dog, apparently"
redim a(len(s)-1)
for i=1 to len(s)
a(i-1)=mid(s,i,1)
next
bubble a
s1=join(a,"")
wscript.echo s1
</lang>
{{out}}
<pre>
,Taaabcdeeeefghhijkllmnnoooopppqrrrsttuuvwxyyz
</pre>
=={{header|Wren}}==
Well, we'll write a function for a bubble sort which we don't have in Wren-sort because it's normally much slower than the other methods. However, it's fast enough here.