Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Alphabetical sort of characters within a string.
#8
Code: (Select All)
Print OrderIt("apple")
Print OrderIt("cheeseburger")

Function OrderIt$ (word$)
    Dim temp(255) As _Byte
    For i = 1 To Len(word$)
        a = Asc(word$, i)
        temp(a) = temp(a) + 1
    Next
    For j = 0 To 255
        o$ = o$ + String$(temp(j), j)
    Next
    OrderIt$ = o$
End Function

And that's all there is to it!  Wink



Edit: @bplus I bet this is faster than yours, as all it does is create a simple array and then directly stores the values in that array. No string counting, positioning, or manipulation needed here! Jst count, then build. Smile
Reply


Messages In This Thread
RE: Alphabetical sort of characters within a string. - by SMcNeill - 04-24-2024, 07:52 PM



Users browsing this thread: 2 Guest(s)