-
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.
-
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.
-
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!
-
Thank you very much, I'm going to try these.