vb.net - Ordering columns in datatable -


so, have function takes in datatable , orders users 2 columns. (rank , ordercount)

function determinebestuser(byval usertable datatable)     dim bestchoice datarow()      u = 0 usertable.rows.count - 1         if not doesprocessorneedorders(usertable.rows(u).item("username"), usertable.rows(u).item("amount"))             usertable.rows(u).delete()         end if     next      bestchoice = usertable.select("", "rank asc, ordercount desc")      if isdbnull(usertable)         console.writeline("no user qualified order @ moment")     end if     return bestchoice(0)(0).tostring end function 

the problem function works correctly , gives me user highest rank (1 or 2) , lowest ordercount (0 - 30+). however, not return correct person. thing i've seen fixes changing "ordercount desc" "ordercount asc"; however, change works specific order , it's returning wrong person.


i have test runs show in more detail: r1 & r2 = rank 1 or 2 / "ordercount"

rank asc, ordercount asc #1 dane-r2 / 12 jerm-r1 / 15 tulsa-r1 / 5 ---picks jerm (should pick tulsa) #2 dane-r2 / 14 jerm-r2 / 15 kate- r2 / 15 ---picks dane  #3 dane-r2 / 15 jerm-r2 / 5 kate-r2 / 5 ---picks dane (should pick jerm or kate) 

rank asc, ordercount desc #1 dane-r2 / 12 jerm-r1 / 15 tulsa-r1 / 5 ---picks tulsa  #2 dane-r2 / 14 jerm-r2 / 15 kate- r2 / 15 ---picks jerm (should pick dane) #3 dane-r2 / 15 jerm-r2 / 5 kate-r2 / 5 ---picks jerm  

it looks it's treating ordercount string value, instead of numeric value, , therefore sorting lexically instead of numerically. type column?

you'll have same problem rank column, if enough ranks 2 digits.

also, example #2 second block, have this:

#2 dane-r2 / 14 jerm-r2 / 15 kate- r2 / 15 ---picks jerm (should pick dane)

in case, jerm correct pick. ranks match, , falls ordercount column, should pick 1 of 15's if you're sorting descending.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -