Results 1 to 3 of 3

Thread: Sorting numbers

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2000
    Posts
    23

    Red face

    I'm wandering if someone can give me the pseaudo code for sorting a range of numbers.Easiest sorting method if possible.


  2. #2
    Guest
    Code:
    Needed:  Listbox
    For i = 0 to 10 'count 0 to number 10
    list1.additem i 'add to list
    Next i 'loop till 10
    That will automatically sort them, or if you want the user to put them in a list:
    list1.additem "1"
    list1.additem "6"
    list1.additem "5"
    list1.additem "3"
    list1.additem "10"
    list1.additem "7"
    list1.additem "2"
    list1.additem "9"
    list1.additem "8"
    list1.additem "4"
    Set the properties list sorted to True.

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    This will sort your array as fast as possible:
    Code:
    Sub Sort(a() As String)
    Dim n&, i&, j&, k&, h
        n = UBound(a)
        k = n \ 2
        While k > 0
        For i = 0 To n - k
            j = i
            While (j >= 0) And (a(j) > a(j + k))
                h = a(j)
                a(j) = a(j + k)
                a(j + k) = h
                If j > k Then
                    j = j - k
                Else
                    j = 0
                End If
            Wend
        Next i
        k = k \ 2
        Wend
    End Sub
    Also for sorting numbers withour loosing the order as above, use format function:
    Code:
    Msgbox Format("12","0000")
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width