Results 1 to 4 of 4

Thread: Sort in a List View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 1999
    Location
    México, D.F.
    Posts
    84

    Smile

    Hi vb-world:

    I have problem with a list view in mode Report, my first column is numeric and consecutive, and when I use the sort property the numbers shows like this, "1,10,11,12... 2,20,21... etc", How can I order or what need to do to the list view order this column consecutively?

    Thanks a lot in advance.
    Regards.
    Angel Maldonado López.
    VB Programmer

  2. #2
    Addicted Member
    Join Date
    Jan 2000
    Location
    Fresno, California, USA
    Posts
    195
    Sorting stuff in listview controls is always a pain. It uses a dumb sort that doesn't take into account what it is sorting. Just for fun, try sorting dates in mm/dd/yyyy format. It sorts everything as if it were a string. I almost always sort before putting into the listview. I've seen workarounds in this forum before, but don't recall what they are.

  3. #3
    New Member
    Join Date
    Nov 1999
    Posts
    3
    If you are inserting data from an array of records you could implement your own sort instead of relying on generally stupid Microsoft sorts. Most common sort procedures are Selection Sort(slowest), Bubble Sort(quick for middle-size databases) and Quick Sort (the quickest one)
    Here's an example of a bubble sort:
    (record is person and we want to sort by field name)

    Procedure Bubblesort (byval numberofrecords)
    declare last,current as integer
    temp as personrecord
    for last = numberofrecords downto 2
    for current = 1 to last-1
    if person(current).name < person(current+1).name then
    temp = person(current)
    person(current) = person(current+1)
    person(current+1) = temp
    endif
    endfor
    endfor
    endproc

    You'll end up having records sorted by name...hope it helps!

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jan 1999
    Location
    México, D.F.
    Posts
    84

    Thumbs up

    Thank you very much, I'm going to try these.
    Angel Maldonado López.
    VB Programmer

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